\Cake\ChronosChronosInterface

An extension to the DateTimeInterface for a friendlier API

Summary

Methods
Constants
now()
copy()
year()
month()
day()
hour()
minute()
second()
setDateTime()
setTimeFromTimeString()
timestamp()
timezone()
tz()
setTimezone()
toDateString()
toFormattedDateString()
toTimeString()
toDateTimeString()
toDayDateTimeString()
toAtomString()
toCookieString()
toIso8601String()
toRfc822String()
toRfc850String()
toRfc1036String()
toRfc1123String()
toRfc2822String()
toRfc3339String()
toRssString()
toW3cString()
eq()
ne()
gt()
gte()
lt()
lte()
between()
closest()
farthest()
min()
max()
isWeekday()
isWeekend()
isYesterday()
isToday()
isTomorrow()
isFuture()
isPast()
isLeapYear()
isSameDay()
isSunday()
isMonday()
isTuesday()
isWednesday()
isThursday()
isFriday()
isSaturday()
isThisWeek()
isThisMonth()
isThisYear()
addYears()
addYear()
subYear()
subYears()
addMonths()
addMonth()
subMonth()
subMonths()
addMonthsWithOverflow()
addMonthWithOverflow()
subMonthWithOverflow()
subMonthsWithOverflow()
addDays()
addDay()
subDay()
subDays()
addWeekdays()
addWeekday()
subWeekday()
subWeekdays()
addWeeks()
addWeek()
subWeek()
subWeeks()
addHours()
addHour()
subHour()
subHours()
addMinutes()
addMinute()
subMinute()
subMinutes()
addSeconds()
addSecond()
subSecond()
subSeconds()
diffForHumans()
diffInYears()
diffInMonths()
diffInWeeks()
diffInDays()
diffInDaysFiltered()
diffInHoursFiltered()
diffFiltered()
diffInWeekdays()
diffInWeekendDays()
diffInHours()
diffInMinutes()
diffInSeconds()
secondsSinceMidnight()
secondsUntilEndOfDay()
startOfDay()
endOfDay()
startOfMonth()
endOfMonth()
startOfYear()
endOfYear()
startOfDecade()
endOfDecade()
startOfCentury()
endOfCentury()
startOfWeek()
endOfWeek()
next()
previous()
firstOfMonth()
lastOfMonth()
nthOfMonth()
firstOfQuarter()
lastOfQuarter()
nthOfQuarter()
firstOfYear()
lastOfYear()
nthOfYear()
average()
isBirthday()
wasWithinLast()
isWithinNext()
isMutable()
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
SUNDAY
YEARS_PER_CENTURY
YEARS_PER_DECADE
MONTHS_PER_YEAR
MONTHS_PER_QUARTER
WEEKS_PER_YEAR
DAYS_PER_WEEK
HOURS_PER_DAY
MINUTES_PER_HOUR
SECONDS_PER_MINUTE
DEFAULT_TO_STRING_FORMAT
No protected methods found
N/A
No private methods found
N/A

Constants

MONDAY

MONDAY = 1

The day constants

TUESDAY

TUESDAY = 2

WEDNESDAY

WEDNESDAY = 3

THURSDAY

THURSDAY = 4

FRIDAY

FRIDAY = 5

SATURDAY

SATURDAY = 6

SUNDAY

SUNDAY = 7

YEARS_PER_CENTURY

YEARS_PER_CENTURY = 100

Number of X in Y

YEARS_PER_DECADE

YEARS_PER_DECADE = 10

MONTHS_PER_YEAR

MONTHS_PER_YEAR = 12

MONTHS_PER_QUARTER

MONTHS_PER_QUARTER = 3

WEEKS_PER_YEAR

WEEKS_PER_YEAR = 52

DAYS_PER_WEEK

DAYS_PER_WEEK = 7

HOURS_PER_DAY

HOURS_PER_DAY = 24

MINUTES_PER_HOUR

MINUTES_PER_HOUR = 60

SECONDS_PER_MINUTE

SECONDS_PER_MINUTE = 60

DEFAULT_TO_STRING_FORMAT

DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s' : string

Default format to use for __toString method when type juggling occurs.

Methods

now()

now(\DateTimeZone|string|null  $tz) : static

Get a ChronosInterface instance for the current date and time

Parameters

\DateTimeZone|string|null $tz

The DateTimeZone object or timezone name.

Returns

static

copy()

copy() : static

Get a copy of the instance

Returns

static

year()

year(integer  $value) : static

Set the instance's year

Parameters

integer $value

The year value.

Returns

static

month()

month(integer  $value) : static

Set the instance's month

Parameters

integer $value

The month value.

Returns

static

day()

day(integer  $value) : static

Set the instance's day

Parameters

integer $value

The day value.

Returns

static

hour()

hour(integer  $value) : static

Set the instance's hour

Parameters

integer $value

The hour value.

Returns

static

minute()

minute(integer  $value) : static

Set the instance's minute

Parameters

integer $value

The minute value.

Returns

static

second()

second(integer  $value) : static

Set the instance's second

Parameters

integer $value

The seconds value.

Returns

static

setDateTime()

setDateTime(integer  $year, integer  $month, integer  $day, integer  $hour, integer  $minute, integer  $second) : static

Set the date and time all together

Parameters

integer $year

The year to set.

integer $month

The month to set.

integer $day

The day to set.

integer $hour

The hour to set.

integer $minute

The minute to set.

integer $second

The second to set.

Returns

static

setTimeFromTimeString()

setTimeFromTimeString(string  $time) : static

Set the time by time string

Parameters

string $time

Time as string.

Returns

static

timestamp()

timestamp(integer  $value) : static

Set the instance's timestamp

Parameters

integer $value

The timestamp value to set.

Returns

static

timezone()

timezone(\DateTimeZone|string  $value) : static

Alias for setTimezone()

Parameters

\DateTimeZone|string $value

The DateTimeZone object or timezone name to use.

Returns

static

tz()

tz(\DateTimeZone|string  $value) : static

Alias for setTimezone()

Parameters

\DateTimeZone|string $value

The DateTimeZone object or timezone name to use.

Returns

static

setTimezone()

setTimezone(\DateTimeZone|string  $value) : static

Set the instance's timezone from a string or object

Parameters

\DateTimeZone|string $value

The DateTimeZone object or timezone name to use.

Returns

static

toDateString()

toDateString() : string

Format the instance as date

Returns

string

toFormattedDateString()

toFormattedDateString() : string

Format the instance as a readable date

Returns

string

toTimeString()

toTimeString() : string

Format the instance as time

Returns

string

toDateTimeString()

toDateTimeString() : string

Format the instance as date and time

Returns

string

toDayDateTimeString()

toDayDateTimeString() : string

Format the instance with day, date and time

Returns

string

toAtomString()

toAtomString() : string

Format the instance as ATOM

Returns

string

toCookieString()

toCookieString() : string

Format the instance as COOKIE

Returns

string

toIso8601String()

toIso8601String() : string

Format the instance as ISO8601

Returns

string

toRfc822String()

toRfc822String() : string

Format the instance as RFC822

Returns

string

toRfc850String()

toRfc850String() : string

Format the instance as RFC850

Returns

string

toRfc1036String()

toRfc1036String() : string

Format the instance as RFC1036

Returns

string

toRfc1123String()

toRfc1123String() : string

Format the instance as RFC1123

Returns

string

toRfc2822String()

toRfc2822String() : string

Format the instance as RFC2822

Returns

string

toRfc3339String()

toRfc3339String() : string

Format the instance as RFC3339

Returns

string

toRssString()

toRssString() : string

Format the instance as RSS

Returns

string

toW3cString()

toW3cString() : string

Format the instance as W3C

Returns

string

eq()

eq(\Cake\Chronos\ChronosInterface  $dt) : boolean

Determines if the instance is equal to another

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

ne()

ne(\Cake\Chronos\ChronosInterface  $dt) : boolean

Determines if the instance is not equal to another

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

gt()

gt(\Cake\Chronos\ChronosInterface  $dt) : boolean

Determines if the instance is greater (after) than another

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

gte()

gte(\Cake\Chronos\ChronosInterface  $dt) : boolean

Determines if the instance is greater (after) than or equal to another

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

lt()

lt(\Cake\Chronos\ChronosInterface  $dt) : boolean

Determines if the instance is less (before) than another

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

lte()

lte(\Cake\Chronos\ChronosInterface  $dt) : boolean

Determines if the instance is less (before) or equal to another

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

between()

between(\Cake\Chronos\ChronosInterface  $dt1, \Cake\Chronos\ChronosInterface  $dt2, boolean  $equal = true) : boolean

Determines if the instance is between two others

Parameters

\Cake\Chronos\ChronosInterface $dt1

The instance to compare with.

\Cake\Chronos\ChronosInterface $dt2

The instance to compare with.

boolean $equal

Indicates if a > and < comparison should be used or <= or >=

Returns

boolean

closest()

closest(\Cake\Chronos\ChronosInterface  $dt1, \Cake\Chronos\ChronosInterface  $dt2) : static

Get the closest date from the instance.

Parameters

\Cake\Chronos\ChronosInterface $dt1

The instance to compare with.

\Cake\Chronos\ChronosInterface $dt2

The instance to compare with.

Returns

static

farthest()

farthest(\Cake\Chronos\ChronosInterface  $dt1, \Cake\Chronos\ChronosInterface  $dt2) : static

Get the farthest date from the instance.

Parameters

\Cake\Chronos\ChronosInterface $dt1

The instance to compare with.

\Cake\Chronos\ChronosInterface $dt2

The instance to compare with.

Returns

static

min()

min(\Cake\Chronos\ChronosInterface|null  $dt = null) : static

Get the minimum instance between a given instance (default now) and the current instance.

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to compare with.

Returns

static

max()

max(\Cake\Chronos\ChronosInterface|null  $dt = null) : static

Get the maximum instance between a given instance (default now) and the current instance.

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to compare with.

Returns

static

isWeekday()

isWeekday() : boolean

Determines if the instance is a weekday

Returns

boolean

isWeekend()

isWeekend() : boolean

Determines if the instance is a weekend day

Returns

boolean

isYesterday()

isYesterday() : boolean

Determines if the instance is yesterday

Returns

boolean

isToday()

isToday() : boolean

Determines if the instance is today

Returns

boolean

isTomorrow()

isTomorrow() : boolean

Determines if the instance is tomorrow

Returns

boolean

isFuture()

isFuture() : boolean

Determines if the instance is in the future, ie. greater (after) than now

Returns

boolean

isPast()

isPast() : boolean

Determines if the instance is in the past, ie. less (before) than now

Returns

boolean

isLeapYear()

isLeapYear() : boolean

Determines if the instance is a leap year

Returns

boolean

isSameDay()

isSameDay(\Cake\Chronos\ChronosInterface  $dt) : boolean

Checks if the passed in date is the same day as the instance current day.

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to check against.

Returns

boolean

isSunday()

isSunday() : boolean

Checks if this day is a Sunday.

Returns

boolean

isMonday()

isMonday() : boolean

Checks if this day is a Monday.

Returns

boolean

isTuesday()

isTuesday() : boolean

Checks if this day is a Tuesday.

Returns

boolean

isWednesday()

isWednesday() : boolean

Checks if this day is a Wednesday.

Returns

boolean

isThursday()

isThursday() : boolean

Checks if this day is a Thursday.

Returns

boolean

isFriday()

isFriday() : boolean

Checks if this day is a Friday.

Returns

boolean

isSaturday()

isSaturday() : boolean

Checks if this day is a Saturday.

Returns

boolean

isThisWeek()

isThisWeek() : boolean

Returns true if this object represents a date within the current week

Returns

boolean

isThisMonth()

isThisMonth() : boolean

Returns true if this object represents a date within the current month

Returns

boolean

isThisYear()

isThisYear() : boolean

Returns true if this object represents a date within the current year

Returns

boolean

addYears()

addYears(integer  $value) : static

Add years to the instance. Positive $value travel forward while negative $value travel into the past.

Parameters

integer $value

The number of years to add.

Returns

static

addYear()

addYear(integer  $value = 1) : static

Add a year to the instance

Parameters

integer $value

The number of years to add.

Returns

static

subYear()

subYear(integer  $value = 1) : static

Remove a year from the instance

Parameters

integer $value

The number of years to remove.

Returns

static

subYears()

subYears(integer  $value) : static

Remove years from the instance.

Parameters

integer $value

The number of years to remove.

Returns

static

addMonths()

addMonths(integer  $value) : static

Add months to the instance. Positive $value travels forward while negative $value travels into the past.

When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.

Example:

 (new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03

 (new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28

Parameters

integer $value

The number of months to add.

Returns

static

addMonth()

addMonth(integer  $value = 1) : static

Add a month to the instance

When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.

Example:

 (new Chronos('2015-01-03'))->addMonth(); // Results in 2015-02-03

 (new Chronos('2015-01-31'))->addMonth(); // Results in 2015-02-28

Parameters

integer $value

The number of months to add.

Returns

static

subMonth()

subMonth(integer  $value = 1) : static

Remove a month from the instance

When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.

Example:

 (new Chronos('2015-03-01'))->subMonth(); // Results in 2015-02-01

 (new Chronos('2015-03-31'))->subMonth(); // Results in 2015-02-28

Parameters

integer $value

The number of months to remove.

Returns

static

subMonths()

subMonths(integer  $value) : static

Remove months from the instance

When adding or subtracting months, if the resulting time is a date that does not exist, the result of this operation will always be the last day of the intended month.

Example:

 (new Chronos('2015-03-01'))->subMonths(1); // Results in 2015-02-01

 (new Chronos('2015-03-31'))->subMonths(1); // Results in 2015-02-28

Parameters

integer $value

The number of months to remove.

Returns

static

addMonthsWithOverflow()

addMonthsWithOverflow(integer  $value) : static

Add months with overflowing to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of months to add.

Returns

static

addMonthWithOverflow()

addMonthWithOverflow(integer  $value = 1) : static

Add a month with overflow to the instance

Parameters

integer $value

The number of months to add.

Returns

static

subMonthWithOverflow()

subMonthWithOverflow(integer  $value = 1) : static

Remove a month with overflow from the instance

Parameters

integer $value

The number of months to remove.

Returns

static

subMonthsWithOverflow()

subMonthsWithOverflow(integer  $value) : static

Remove months with overflow from the instance

Parameters

integer $value

The number of months to remove.

Returns

static

addDays()

addDays(integer  $value) : static

Add days to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of days to add.

Returns

static

addDay()

addDay(integer  $value = 1) : static

Add a day to the instance

Parameters

integer $value

The number of days to add.

Returns

static

subDay()

subDay(integer  $value = 1) : static

Remove a day from the instance

Parameters

integer $value

The number of days to remove.

Returns

static

subDays()

subDays(integer  $value) : static

Remove days from the instance

Parameters

integer $value

The number of days to remove.

Returns

static

addWeekdays()

addWeekdays(integer  $value) : static

Add weekdays to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of weekdays to add.

Returns

static

addWeekday()

addWeekday(integer  $value = 1) : static

Add a weekday to the instance

Parameters

integer $value

The number of weekdays to add.

Returns

static

subWeekday()

subWeekday(integer  $value = 1) : static

Remove a weekday from the instance

Parameters

integer $value

The number of weekdays to remove.

Returns

static

subWeekdays()

subWeekdays(integer  $value) : static

Remove weekdays from the instance

Parameters

integer $value

The number of weekdays to remove.

Returns

static

addWeeks()

addWeeks(integer  $value) : static

Add weeks to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of weeks to add.

Returns

static

addWeek()

addWeek(integer  $value = 1) : static

Add a week to the instance

Parameters

integer $value

The number of weeks to add.

Returns

static

subWeek()

subWeek(integer  $value = 1) : static

Remove a week from the instance

Parameters

integer $value

The number of weeks to remove.

Returns

static

subWeeks()

subWeeks(integer  $value) : static

Remove weeks to the instance

Parameters

integer $value

The number of weeks to remove.

Returns

static

addHours()

addHours(integer  $value) : static

Add hours to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of hours to add.

Returns

static

addHour()

addHour(integer  $value = 1) : static

Add an hour to the instance

Parameters

integer $value

The number of hours to add.

Returns

static

subHour()

subHour(integer  $value = 1) : static

Remove an hour from the instance

Parameters

integer $value

The number of hours to remove.

Returns

static

subHours()

subHours(integer  $value) : static

Remove hours from the instance

Parameters

integer $value

The number of hours to remove.

Returns

static

addMinutes()

addMinutes(integer  $value) : static

Add minutes to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of minutes to add.

Returns

static

addMinute()

addMinute(integer  $value = 1) : static

Add a minute to the instance

Parameters

integer $value

The number of minutes to add.

Returns

static

subMinute()

subMinute(integer  $value = 1) : static

Remove a minute from the instance

Parameters

integer $value

The number of minutes to remove.

Returns

static

subMinutes()

subMinutes(integer  $value) : static

Remove minutes from the instance

Parameters

integer $value

The number of minutes to remove.

Returns

static

addSeconds()

addSeconds(integer  $value) : static

Add seconds to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

integer $value

The number of seconds to add.

Returns

static

addSecond()

addSecond(integer  $value = 1) : static

Add a second to the instance

Parameters

integer $value

The number of seconds to add.

Returns

static

subSecond()

subSecond(integer  $value = 1) : static

Remove a second from the instance

Parameters

integer $value

The number of seconds to remove.

Returns

static

subSeconds()

subSeconds(integer  $value) : static

Remove seconds from the instance

Parameters

integer $value

The number of seconds to remove.

Returns

static

diffForHumans()

diffForHumans(\Cake\Chronos\ChronosInterface|null  $other = null, boolean  $absolute = false) : string

Get the difference in a human readable format in the current locale.

When comparing a value in the past to default now: 1 hour ago 5 months ago

When comparing a value in the future to default now: 1 hour from now 5 months from now

When comparing a value in the past to another value: 1 hour before 5 months before

When comparing a value in the future to another value: 1 hour after 5 months after

Parameters

\Cake\Chronos\ChronosInterface|null $other

The datetime to compare with.

boolean $absolute

Removes time difference modifiers ago, after, etc

Returns

string

diffInYears()

diffInYears(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in years

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInMonths()

diffInMonths(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in months

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInWeeks()

diffInWeeks(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in weeks

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInDays()

diffInDays(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in days

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInDaysFiltered()

diffInDaysFiltered(callable  $callback, \Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in days using a filter callable

Parameters

callable $callback

The callback to use for filtering.

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInHoursFiltered()

diffInHoursFiltered(callable  $callback, \Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in hours using a filter callable

Parameters

callable $callback

The callback to use for filtering.

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffFiltered()

diffFiltered(\Cake\Chronos\ChronosInterval  $ci, callable  $callback, \Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference by the given interval using a filter callable

Parameters

\Cake\Chronos\ChronosInterval $ci

An interval to traverse by

callable $callback

The callback to use for filtering.

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInWeekdays()

diffInWeekdays(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in weekdays

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInWeekendDays()

diffInWeekendDays(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in weekend days using a filter

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInHours()

diffInHours(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in hours

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInMinutes()

diffInMinutes(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in minutes

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

diffInSeconds()

diffInSeconds(\Cake\Chronos\ChronosInterface|null  $dt = null, boolean  $abs = true) : integer

Get the difference in seconds

Parameters

\Cake\Chronos\ChronosInterface|null $dt

The instance to difference from.

boolean $abs

Get the absolute of the difference

Returns

integer

secondsSinceMidnight()

secondsSinceMidnight() : integer

The number of seconds since midnight.

Returns

integer

secondsUntilEndOfDay()

secondsUntilEndOfDay() : integer

The number of seconds until 23:59:59.

Returns

integer

startOfDay()

startOfDay() : static

Resets the time to 00:00:00

Returns

static

endOfDay()

endOfDay() : static

Resets the time to 23:59:59

Returns

static

startOfMonth()

startOfMonth() : static

Resets the date to the first day of the month and the time to 00:00:00

Returns

static

endOfMonth()

endOfMonth() : static

Resets the date to end of the month and time to 23:59:59

Returns

static

startOfYear()

startOfYear() : static

Resets the date to the first day of the year and the time to 00:00:00

Returns

static

endOfYear()

endOfYear() : static

Resets the date to end of the year and time to 23:59:59

Returns

static

startOfDecade()

startOfDecade() : static

Resets the date to the first day of the decade and the time to 00:00:00

Returns

static

endOfDecade()

endOfDecade() : static

Resets the date to end of the decade and time to 23:59:59

Returns

static

startOfCentury()

startOfCentury() : static

Resets the date to the first day of the century and the time to 00:00:00

Returns

static

endOfCentury()

endOfCentury() : static

Resets the date to end of the century and time to 23:59:59

Returns

static

startOfWeek()

startOfWeek() : static

Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00

Returns

static

endOfWeek()

endOfWeek() : static

Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59

Returns

static

next()

next(integer  $dayOfWeek = null) : mixed

Modify to the next occurrence of a given day of the week.

If no dayOfWeek is provided, modify to the next occurrence of the current day of the week. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

previous()

previous(integer  $dayOfWeek = null) : mixed

Modify to the previous occurrence of a given day of the week.

If no dayOfWeek is provided, modify to the previous occurrence of the current day of the week. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

firstOfMonth()

firstOfMonth(integer  $dayOfWeek = null) : mixed

Modify to the first occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the first day of the current month. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

lastOfMonth()

lastOfMonth(integer  $dayOfWeek = null) : mixed

Modify to the last occurrence of a given day of the week in the current month. If no dayOfWeek is provided, modify to the last day of the current month. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

nthOfMonth()

nthOfMonth(integer  $nth, integer  $dayOfWeek) : mixed

Modify to the given occurrence of a given day of the week in the current month. If the calculated occurrence is outside the scope of the current month, then return false and no modifications are made.

Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $nth

The offset to use.

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

firstOfQuarter()

firstOfQuarter(integer  $dayOfWeek = null) : mixed

Modify to the first occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the first day of the current quarter. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

lastOfQuarter()

lastOfQuarter(integer  $dayOfWeek = null) : mixed

Modify to the last occurrence of a given day of the week in the current quarter. If no dayOfWeek is provided, modify to the last day of the current quarter. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

nthOfQuarter()

nthOfQuarter(integer  $nth, integer  $dayOfWeek) : mixed

Modify to the given occurrence of a given day of the week in the current quarter. If the calculated occurrence is outside the scope of the current quarter, then return false and no modifications are made.

Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $nth

The offset to use.

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

firstOfYear()

firstOfYear(integer  $dayOfWeek = null) : mixed

Modify to the first occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the first day of the current year. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

lastOfYear()

lastOfYear(integer  $dayOfWeek = null) : mixed

Modify to the last occurrence of a given day of the week in the current year. If no dayOfWeek is provided, modify to the last day of the current year. Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

nthOfYear()

nthOfYear(integer  $nth, integer  $dayOfWeek) : mixed

Modify to the given occurrence of a given day of the week in the current year. If the calculated occurrence is outside the scope of the current year, then return false and no modifications are made.

Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY.

Parameters

integer $nth

The offset to use.

integer $dayOfWeek

The day of the week to move to.

Returns

mixed

average()

average(\Cake\Chronos\ChronosInterface  $dt = null) : static

Modify the current instance to the average of a given instance (default now) and the current instance.

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

static

isBirthday()

isBirthday(\Cake\Chronos\ChronosInterface  $dt) : boolean

Check if its the birthday. Compares the date/month values of the two dates.

Parameters

\Cake\Chronos\ChronosInterface $dt

The instance to compare with.

Returns

boolean

wasWithinLast()

wasWithinLast(string|integer  $timeInterval) : boolean

Returns true this instance happened within the specified interval

Parameters

string|integer $timeInterval

the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.

Returns

boolean

isWithinNext()

isWithinNext(string|integer  $timeInterval) : boolean

Returns true this instance will happen within the specified interval

Parameters

string|integer $timeInterval

the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.

Returns

boolean

isMutable()

isMutable() : boolean

Check if instance of ChronosInterface is mutable.

Returns

boolean