Interface for date formatting methods shared by both Time & Date.
int 7
string 'Y-m-d H:i:s'
Default format to use for __toString method when type juggling occurs.
int 5
int 24
int 60
int 1
int 3
int 12
int 6
int 60
int 7
int 4
int 2
int 3
int 52
int 100
int 10
Add a day to the instance
Add days to the instance. Positive $value travels forward while negative $value travels into the past.
Add an hour to the instance
Add hours to the instance. Positive $value travels forward while negative $value travels into the past.
Add a minute to the instance
Add minutes to the instance. Positive $value travels forward while negative $value travels into the past.
Add a month to the instance.
Add a month with overflow to the instance.
Add months to the instance. Positive $value travels forward while negative $value travels into the past.
Add months with overflowing to the instance. Positive $value travels forward while negative $value travels into the past.
Add a second to the instance
Add seconds to the instance. Positive $value travels forward while negative $value travels into the past.
Add a week to the instance
Add a weekday to the instance
Add weekdays to the instance. Positive $value travels forward while negative $value travels into the past.
Add weeks to the instance. Positive $value travels forward while negative $value travels into the past.
Add a year to the instance
Add a year with overflow to the instance
Add years to the instance. Positive $value travel forward while negative $value travel into the past.
Add years with overflowing to the instance. Positive $value travels forward while negative $value travels into the past.
Modify the current instance to the average of a given instance (default now) and the current instance.
Determines if the instance is between two others
Get the closest date from the instance.
Get a copy of the instance
Set the instance's day
Get the difference by the given interval using a filter callable
Get the difference in a human readable format in the current locale.
Get the difference in days
Get the difference in days using a filter callable
Get the difference in hours
Get the difference in hours using a filter callable
Get the difference in minutes
Get the difference in months
Get the difference in seconds
Get the difference in weekdays
Get the difference in weekend days using a filter
Get the difference in weeks
Get the difference in years
Resets the date to end of the century and time to 23:59:59
Resets the time to 23:59:59
Resets the date to end of the decade and time to 23:59:59
Resets the date to end of the month and time to 23:59:59
Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59
Resets the date to end of the year and time to 23:59:59
Determines if the instance is equal to another
Determines if the instance is equal to another
Get the farthest date from the instance.
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.
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.
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.
Gets the default locale.
Get the difference formatter instance.
Determines if the instance is greater (after) than another
Determines if the instance is greater (after) than or equal to another
Determines if the instance is greater (after) than another
Determines if the instance is greater (after) than or equal to another
Set the instance's hour
Returns a formatted string for this time object using the preferred format and language for the specified locale.
Check if its the birthday. Compares the date/month values of the two dates.
Checks if this day is a Friday.
Determines if the instance is in the future, ie. greater (after) than now
Determines if the instance is a leap year
Checks if this day is a Monday.
Check if instance of ChronosInterface is mutable.
Determines if the instance is in the past, ie. less (before) than now
Checks if the passed in date is the same day as the instance current day.
Checks if this day is a Saturday.
Checks if this day is a Sunday.
Returns true if this object represents a date within the current month
Returns true if this object represents a date within the current week
Returns true if this object represents a date within the current year
Checks if this day is a Thursday.
Determines if the instance is today
Determines if the instance is tomorrow
Checks if this day is a Tuesday.
Checks if this day is a Wednesday.
Determines if the instance is a weekday
Determines if the instance is a weekend day
Returns true this instance will happen within the specified interval
Determines if the instance is yesterday
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.
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.
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.
Determines if the instance is less (before) than another
Determines if the instance is less (before) or equal to another
Determines if the instance is less (before) than another
Determines if the instance is less (before) or equal to another
Get the maximum instance between a given instance (default now) and the current instance.
Get the minimum instance between a given instance (default now) and the current instance.
Set the instance's minute
Set the instance's month
Determines if the instance is not equal to another
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.
Returns a nicely formatted date string for this object.
Determines if the instance is not equal to another
Get a ChronosInterface instance for the current date and time
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.
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.
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.
Returns a new Time object after parsing the provided $date string based on the passed or configured date time format. This method is locale dependent, Any string that is passed to this function will be interpreted as a locale dependent string.
Returns a new Time object after parsing the provided time string based on the passed or configured date time format. This method is locale dependent, Any string that is passed to this function will be interpreted as a locale dependent string.
Returns a new Time object after parsing the provided $time string based on the passed or configured date time format. This method is locale dependent, Any string that is passed to this function will be interpreted as a locale dependent string.
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.
Resets the format used to the default when converting an instance of this type to a string
Set the instance's second
The number of seconds since midnight.
The number of seconds until 23:59:59.
Set the date and time all together
Sets the default locale.
Set the difference formatter instance.
Sets the default format used when converting this object to JSON
Set the time by time string
Set the instance's timezone from a string or object
Sets the default format used when type converting instances of this type to string
Resets the date to the first day of the century and the time to 00:00:00
Resets the time to 00:00:00
Resets the date to the first day of the decade and the time to 00:00:00
Resets the date to the first day of the month and the time to 00:00:00
Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
Resets the date to the first day of the year and the time to 00:00:00
Remove a day from the instance
Remove days from the instance
Remove an hour from the instance
Remove hours from the instance
Remove a minute from the instance
Remove minutes from the instance
Remove a month from the instance
Remove a month with overflow from the instance.
Remove months from the instance.
Remove months with overflow from the instance.
Remove a second from the instance
Remove seconds from the instance
Remove a week from the instance
Remove a weekday from the instance
Remove weekdays from the instance
Remove weeks to the instance
Remove a year from the instance.
Remove a year with overflow from the instance
Remove years from the instance.
Remove years with overflow from the instance
Set the instance's timestamp
Alias for setTimezone()
Format the instance as ATOM
Format the instance as COOKIE
Format the instance as date
Format the instance as date and time
Format the instance with day, date and time
Format the instance as a readable date
Format the instance as ISO8601
Format the instance as RFC1036
Format the instance as RFC1123
Format the instance as RFC2822
Format the instance as RFC3339
Format the instance as RFC822
Format the instance as RFC850
Format the instance as RSS
Format the instance as time
Format the instance as W3C
Alias for setTimezone()
Returns true this instance happened within the specified interval
Set the instance's year
addDay(int $value = 1): static
Add a day to the instance
int $value optional The number of days to add.
staticaddDays(int $value): static
Add days to the instance. Positive $value travels forward while negative $value travels into the past.
int $value The number of days to add.
staticaddHour(int $value = 1): static
Add an hour to the instance
int $value optional The number of hours to add.
staticaddHours(int $value): static
Add hours to the instance. Positive $value travels forward while negative $value travels into the past.
int $value The number of hours to add.
staticaddMinute(int $value = 1): static
Add a minute to the instance
int $value optional The number of minutes to add.
staticaddMinutes(int $value): static
Add minutes to the instance. Positive $value travels forward while negative $value travels into the past.
int $value The number of minutes to add.
staticaddMonth(int $value = 1): static
Add a month to the instance.
Has the same behavior as addMonths().
int $value optional The number of months to add.
staticaddMonthWithOverflow(int $value = 1): static
Add a month with overflow to the instance.
Has the same behavior as addMonthsWithOverflow().
int $value optional The number of months to add.
staticaddMonths(int $value): static
Add months to the instance. Positive $value travels forward while negative $value travels into the past.
If the new date does not exist, the last day of the month is used instead instead of overflowing into the next month.
(new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03
(new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28 int $value The number of months to add.
staticaddMonthsWithOverflow(int $value): static
Add months with overflowing to the instance. Positive $value travels forward while negative $value travels into the past.
If the new date does not exist, the days overflow into the next month.
(new Chronos('2012-01-30'))->addMonthsWithOverflow(1); // Results in 2013-03-01 int $value The number of months to add.
staticaddSecond(int $value = 1): static
Add a second to the instance
int $value optional The number of seconds to add.
staticaddSeconds(int $value): static
Add seconds to the instance. Positive $value travels forward while negative $value travels into the past.
int $value The number of seconds to add.
staticaddWeek(int $value = 1): static
Add a week to the instance
int $value optional The number of weeks to add.
staticaddWeekday(int $value = 1): static
Add a weekday to the instance
int $value optional The number of weekdays to add.
staticaddWeekdays(int $value): static
Add weekdays to the instance. Positive $value travels forward while negative $value travels into the past.
int $value The number of weekdays to add.
staticaddWeeks(int $value): static
Add weeks to the instance. Positive $value travels forward while negative $value travels into the past.
int $value The number of weeks to add.
staticaddYear(int $value = 1): static
Add a year to the instance
Has the same behavior as addYears().
int $value optional The number of years to add.
staticaddYearWithOverflow(int $value = 1): static
Add a year with overflow to the instance
Has the same behavior as addYearsWithOverflow().
int $value optional The number of years to add.
staticaddYears(int $value): static
Add years to the instance. Positive $value travel forward while negative $value travel into the past.
If the new date does not exist, the last day of the month is used instead instead of overflowing into the next month.
(new Chronos('2015-01-03'))->addYears(1); // Results in 2016-01-03
(new Chronos('2012-02-29'))->addYears(1); // Results in 2013-02-28 int $value The number of years to add.
staticaddYearsWithOverflow(int $value): static
Add years with overflowing to the instance. Positive $value travels forward while negative $value travels into the past.
If the new date does not exist, the days overflow into the next month.
(new Chronos('2012-02-29'))->addYearsWithOverflow(1); // Results in 2013-03-01 int $value The number of years to add.
staticaverage(Cake\Chronos\ChronosInterface $dt = null): static
Modify the current instance to the average of a given instance (default now) and the current instance.
Cake\Chronos\ChronosInterface $dt optional The instance to compare with.
staticbetween(Cake\Chronos\ChronosInterface $dt1, Cake\Chronos\ChronosInterface $dt2, bool $equal = true): bool
Determines if the instance is between two others
Cake\Chronos\ChronosInterface $dt1 The instance to compare with.
Cake\Chronos\ChronosInterface $dt2 The instance to compare with.
bool $equal optional Indicates if a > and < comparison should be used or <= or >=
boolclosest(Cake\Chronos\ChronosInterface $dt1, Cake\Chronos\ChronosInterface $dt2): static
Get the closest date from the instance.
Cake\Chronos\ChronosInterface $dt1 The instance to compare with.
Cake\Chronos\ChronosInterface $dt2 The instance to compare with.
staticcopy(): static
Get a copy of the instance
staticday(int $value): static
Set the instance's day
int $value The day value.
staticdiffFiltered(Cake\Chronos\ChronosInterval $ci, callable $callback, Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference by the given interval using a filter callable
Cake\Chronos\ChronosInterval $ci An interval to traverse by
callable $callback The callback to use for filtering.
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffForHumans(Cake\Chronos\ChronosInterface|null $other = null, bool $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
Cake\Chronos\ChronosInterface|null $other optional The datetime to compare with.
bool $absolute optional Removes time difference modifiers ago, after, etc
stringdiffInDays(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in days
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInDaysFiltered(callable $callback, Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in days using a filter callable
callable $callback The callback to use for filtering.
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInHours(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in hours
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInHoursFiltered(callable $callback, Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in hours using a filter callable
callable $callback The callback to use for filtering.
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInMinutes(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in minutes
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInMonths(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in months
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInSeconds(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in seconds
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInWeekdays(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in weekdays
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInWeekendDays(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in weekend days using a filter
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInWeeks(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in weeks
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intdiffInYears(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): int
Get the difference in years
Cake\Chronos\ChronosInterface|null $dt optional The instance to difference from.
bool $abs optional Get the absolute of the difference
intendOfCentury(): static
Resets the date to end of the century and time to 23:59:59
staticendOfDay(): static
Resets the time to 23:59:59
staticendOfDecade(): static
Resets the date to end of the decade and time to 23:59:59
staticendOfMonth(): static
Resets the date to end of the month and time to 23:59:59
staticendOfWeek(): static
Resets the date to end of week (defined in $weekEndsAt) and time to 23:59:59
staticendOfYear(): static
Resets the date to end of the year and time to 23:59:59
staticeq(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolequals(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolfarthest(Cake\Chronos\ChronosInterface $dt1, Cake\Chronos\ChronosInterface $dt2): static
Get the farthest date from the instance.
Cake\Chronos\ChronosInterface $dt1 The instance to compare with.
Cake\Chronos\ChronosInterface $dt2 The instance to compare with.
staticfirstOfMonth(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedfirstOfQuarter(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedfirstOfYear(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedgetDefaultLocale(): string|null
Gets the default locale.
string|nullgetDiffFormatter(): Cake\Chronos\DifferenceFormatterInterface
Get the difference formatter instance.
Cake\Chronos\DifferenceFormatterInterfacegreaterThan(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is greater (after) than another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolgreaterThanOrEquals(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is greater (after) than or equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolgt(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is greater (after) than another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolgte(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is greater (after) than or equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolhour(int $value): static
Set the instance's hour
int $value The hour value.
statici18nFormat(string|int|null $format = null, DateTimeZone|string|null $timezone = null, string|null $locale = null): string|int
Returns a formatted string for this time object using the preferred format and language for the specified locale.
It is possible to specify the desired format for the string to be displayed. You can either pass IntlDateFormatter constants as the first argument of this function, or pass a full ICU date formatting string as specified in the following resource: https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classSimpleDateFormat.html#details.
Additional to IntlDateFormatter constants and date formatting string you can use Time::UNIX_TIMESTAMP_FORMAT to get a unix timestamp
$time = new Time('2014-04-20 22:10');
$time->i18nFormat(); // outputs '4/20/14, 10:10 PM' for the en-US locale
$time->i18nFormat(\IntlDateFormatter::FULL); // Use the full date and time format
$time->i18nFormat([\IntlDateFormatter::FULL, \IntlDateFormatter::SHORT]); // Use full date but short time format
$time->i18nFormat('yyyy-MM-dd HH:mm:ss'); // outputs '2014-04-20 22:10'
$time->i18nFormat(Time::UNIX_TIMESTAMP_FORMAT); // outputs '1398031800' If you wish to control the default format to be used for this method, you can alter the value of the static Time::$defaultLocale variable and set it to one of the possible formats accepted by this function.
You can read about the available IntlDateFormatter constants at https://secure.php.net/manual/en/class.intldateformatter.php
If you need to display the date in a different timezone than the one being used for this Time object without altering its internal state, you can pass a timezone string or object as the second parameter.
Finally, should you need to use a different locale for displaying this time object, pass a locale string as the third parameter to this function.
$time = new Time('2014-04-20 22:10');
$time->i18nFormat(null, null, 'de-DE');
$time->i18nFormat(\IntlDateFormatter::FULL, 'Europe/Berlin', 'de-DE'); You can control the default locale to be used by setting the static variable Time::$defaultLocale to a valid locale string. If empty, the default will be taken from the intl.default_locale ini config.
string|int|null $format optional Format string.
DateTimeZone|string|null $timezone optional Timezone string or DateTimeZone object in which the date will be displayed. The timezone stored for this object will not be changed.
string|null $locale optional The locale name in which the date should be displayed (e.g. pt-BR)
string|intisBirthday(Cake\Chronos\ChronosInterface $dt): bool
Check if its the birthday. Compares the date/month values of the two dates.
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolisFriday(): bool
Checks if this day is a Friday.
boolisFuture(): bool
Determines if the instance is in the future, ie. greater (after) than now
boolisLeapYear(): bool
Determines if the instance is a leap year
boolisMonday(): bool
Checks if this day is a Monday.
boolisMutable(): bool
Check if instance of ChronosInterface is mutable.
boolisPast(): bool
Determines if the instance is in the past, ie. less (before) than now
boolisSameDay(Cake\Chronos\ChronosInterface $dt): bool
Checks if the passed in date is the same day as the instance current day.
Cake\Chronos\ChronosInterface $dt The instance to check against.
boolisSaturday(): bool
Checks if this day is a Saturday.
boolisSunday(): bool
Checks if this day is a Sunday.
boolisThisMonth(): bool
Returns true if this object represents a date within the current month
boolisThisWeek(): bool
Returns true if this object represents a date within the current week
boolisThisYear(): bool
Returns true if this object represents a date within the current year
boolisThursday(): bool
Checks if this day is a Thursday.
boolisToday(): bool
Determines if the instance is today
boolisTomorrow(): bool
Determines if the instance is tomorrow
boolisTuesday(): bool
Checks if this day is a Tuesday.
boolisWednesday(): bool
Checks if this day is a Wednesday.
boolisWeekday(): bool
Determines if the instance is a weekday
boolisWeekend(): bool
Determines if the instance is a weekend day
boolisWithinNext(string|int $timeInterval): bool
Returns true this instance will happen within the specified interval
string|int $timeInterval the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.
boolisYesterday(): bool
Determines if the instance is yesterday
boollastOfMonth(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedlastOfQuarter(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedlastOfYear(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedlessThan(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is less (before) than another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boollessThanOrEquals(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is less (before) or equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boollt(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is less (before) than another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boollte(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is less (before) or equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolmax(Cake\Chronos\ChronosInterface|null $dt = null): static
Get the maximum instance between a given instance (default now) and the current instance.
Cake\Chronos\ChronosInterface|null $dt optional The instance to compare with.
staticmin(Cake\Chronos\ChronosInterface|null $dt = null): static
Get the minimum instance between a given instance (default now) and the current instance.
Cake\Chronos\ChronosInterface|null $dt optional The instance to compare with.
staticminute(int $value): static
Set the instance's minute
int $value The minute value.
staticmodify(string $relative): Cake\Chronos\ChronosInterface
string $relative Cake\Chronos\ChronosInterfacemonth(int $value): static
Set the instance's month
int $value The month value.
staticne(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is not equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolnext(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixednice(DateTimeZone|string|null $timezone = null, string|null $locale = null): string
Returns a nicely formatted date string for this object.
The format to be used is stored in the static property Time::niceFormat.
DateTimeZone|string|null $timezone optional Timezone string or DateTimeZone object in which the date will be displayed. The timezone stored for this object will not be changed.
string|null $locale optional The locale name in which the date should be displayed (e.g. pt-BR)
stringnotEquals(Cake\Chronos\ChronosInterface $dt): bool
Determines if the instance is not equal to another
Cake\Chronos\ChronosInterface $dt The instance to compare with.
boolnow(DateTimeZone|string|null $tz): static
Get a ChronosInterface instance for the current date and time
DateTimeZone|string|null $tz The DateTimeZone object or timezone name.
staticnthOfMonth(int $nth, int $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.
int $nth The offset to use.
int $dayOfWeek The day of the week to move to.
mixednthOfQuarter(int $nth, int $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.
int $nth The offset to use.
int $dayOfWeek The day of the week to move to.
mixednthOfYear(int $nth, int $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.
int $nth The offset to use.
int $dayOfWeek The day of the week to move to.
mixedparseDate(string $date, array|string|int|null $format = null): static|null
Returns a new Time object after parsing the provided $date string based on the passed or configured date time format. This method is locale dependent, Any string that is passed to this function will be interpreted as a locale dependent string.
When no $format is provided, the wordFormat format will be used.
If it was impossible to parse the provided time, null will be returned.
Example:
$time = Time::parseDate('10/13/2013');
$time = Time::parseDate('13 Oct, 2013', 'dd MMM, y');
$time = Time::parseDate('13 Oct, 2013', IntlDateFormatter::SHORT); string $date The date string to parse.
array|string|int|null $format optional Any format accepted by IntlDateFormatter.
static|nullparseDateTime(string $time, array<int>|string|null $format = null, DateTimeZone|string|null $tz = null): static|null
Returns a new Time object after parsing the provided time string based on the passed or configured date time format. This method is locale dependent, Any string that is passed to this function will be interpreted as a locale dependent string.
When no $format is provided, the toString format will be used.
If it was impossible to parse the provided time, null will be returned.
Example:
$time = Time::parseDateTime('10/13/2013 12:54am');
$time = Time::parseDateTime('13 Oct, 2013 13:54', 'dd MMM, y H:mm');
$time = Time::parseDateTime('10/10/2015', [IntlDateFormatter::SHORT, -1]); string $time The time string to parse.
array<int>|string|null $format optional Any format accepted by IntlDateFormatter.
DateTimeZone|string|null $tz optional The timezone for the instance
static|nullInvalidArgumentExceptionparseTime(string $time, string|int|null $format = null): static|null
Returns a new Time object after parsing the provided $time string based on the passed or configured date time format. This method is locale dependent, Any string that is passed to this function will be interpreted as a locale dependent string.
When no $format is provided, the IntlDateFormatter::SHORT format will be used.
If it was impossible to parse the provided time, null will be returned.
Example:
$time = Time::parseTime('11:23pm'); string $time The time string to parse.
string|int|null $format optional Any format accepted by IntlDateFormatter.
static|nullprevious(int|null $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.
int|null $dayOfWeek optional The day of the week to move to.
mixedresetToStringFormat(): void
Resets the format used to the default when converting an instance of this type to a string
voidsecond(int $value): static
Set the instance's second
int $value The seconds value.
staticsecondsSinceMidnight(): int
The number of seconds since midnight.
intsecondsUntilEndOfDay(): int
The number of seconds until 23:59:59.
intsetDateTime(int $year, int $month, int $day, int $hour, int $minute, int $second = 0): static
Set the date and time all together
int $year The year to set.
int $month The month to set.
int $day The day to set.
int $hour The hour to set.
int $minute The minute to set.
int $second optional The second to set.
staticsetDefaultLocale(string|null $locale = null): void
Sets the default locale.
string|null $locale optional The default locale string to be used or null.
voidsetDiffFormatter(Cake\Chronos\DifferenceFormatterInterface $formatter): void
Set the difference formatter instance.
Cake\Chronos\DifferenceFormatterInterface $formatter The formatter instance when setting.
voidsetJsonEncodeFormat(Closure|array|string|int $format): void
Sets the default format used when converting this object to JSON
The format should be either the formatting constants from IntlDateFormatter as described in (https://secure.php.net/manual/en/class.intldateformatter.php) or a pattern as specified in (https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classSimpleDateFormat.html#details)
It is possible to provide an array of 2 constants. In this case, the first position will be used for formatting the date part of the object and the second position will be used to format the time part.
Alternatively, the format can provide a callback. In this case, the callback can receive this datetime object and return a formatted string.
Closure|array|string|int $format Format.
voidsetTimeFromTimeString(string $time): static
Set the time by time string
string $time Time as string.
staticsetTimezone(DateTimeZone|string $value): static
Set the instance's timezone from a string or object
DateTimeZone|string $value The DateTimeZone object or timezone name to use.
staticsetToStringFormat(array<int>|string|int $format): void
Sets the default format used when type converting instances of this type to string
array<int>|string|int $format Format.
voidstartOfCentury(): static
Resets the date to the first day of the century and the time to 00:00:00
staticstartOfDay(): static
Resets the time to 00:00:00
staticstartOfDecade(): static
Resets the date to the first day of the decade and the time to 00:00:00
staticstartOfMonth(): static
Resets the date to the first day of the month and the time to 00:00:00
staticstartOfWeek(): static
Resets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
staticstartOfYear(): static
Resets the date to the first day of the year and the time to 00:00:00
staticsubDay(int $value = 1): static
Remove a day from the instance
int $value optional The number of days to remove.
staticsubDays(int $value): static
Remove days from the instance
int $value The number of days to remove.
staticsubHour(int $value = 1): static
Remove an hour from the instance
int $value optional The number of hours to remove.
staticsubHours(int $value): static
Remove hours from the instance
int $value The number of hours to remove.
staticsubMinute(int $value = 1): static
Remove a minute from the instance
int $value optional The number of minutes to remove.
staticsubMinutes(int $value): static
Remove minutes from the instance
int $value The number of minutes to remove.
staticsubMonth(int $value = 1): static
Remove a month from the instance
Has the same behavior as addMonths().
int $value optional The number of months to remove.
staticsubMonthWithOverflow(int $value = 1): static
Remove a month with overflow from the instance.
Has the same behavior as addMonthsWithOverflow().
int $value optional The number of months to remove.
staticsubMonths(int $value): static
Remove months from the instance.
Has the same behavior as addMonths().
int $value The number of months to remove.
staticsubMonthsWithOverflow(int $value): static
Remove months with overflow from the instance.
Has the same behavior as addMonthsWithOverflow().
int $value The number of months to remove.
staticsubSecond(int $value = 1): static
Remove a second from the instance
int $value optional The number of seconds to remove.
staticsubSeconds(int $value): static
Remove seconds from the instance
int $value The number of seconds to remove.
staticsubWeek(int $value = 1): static
Remove a week from the instance
int $value optional The number of weeks to remove.
staticsubWeekday(int $value = 1): static
Remove a weekday from the instance
int $value optional The number of weekdays to remove.
staticsubWeekdays(int $value): static
Remove weekdays from the instance
int $value The number of weekdays to remove.
staticsubWeeks(int $value): static
Remove weeks to the instance
int $value The number of weeks to remove.
staticsubYear(int $value = 1): static
Remove a year from the instance.
Has the same behavior as addYears().
int $value optional The number of years to remove.
staticsubYearWithOverflow(int $value = 1): static
Remove a year with overflow from the instance
Has the same behavior as addYearsWithOverflow().
int $value optional The number of years to remove.
staticsubYears(int $value): static
Remove years from the instance.
Has the same behavior as addYears().
int $value The number of years to remove.
staticsubYearsWithOverflow(int $value): static
Remove years with overflow from the instance
Has the same behavior as addYearsWithOverflow().
int $value The number of years to remove.
statictimestamp(int $value): static
Set the instance's timestamp
int $value The timestamp value to set.
statictimezone(DateTimeZone|string $value): static
Alias for setTimezone()
DateTimeZone|string $value The DateTimeZone object or timezone name to use.
statictoAtomString(): string
Format the instance as ATOM
stringtoCookieString(): string
Format the instance as COOKIE
stringtoDateString(): string
Format the instance as date
stringtoDateTimeString(): string
Format the instance as date and time
stringtoDayDateTimeString(): string
Format the instance with day, date and time
stringtoFormattedDateString(): string
Format the instance as a readable date
stringtoIso8601String(): string
Format the instance as ISO8601
stringtoRfc1036String(): string
Format the instance as RFC1036
stringtoRfc1123String(): string
Format the instance as RFC1123
stringtoRfc2822String(): string
Format the instance as RFC2822
stringtoRfc3339String(): string
Format the instance as RFC3339
stringtoRfc822String(): string
Format the instance as RFC822
stringtoRfc850String(): string
Format the instance as RFC850
stringtoRssString(): string
Format the instance as RSS
stringtoTimeString(): string
Format the instance as time
stringtoW3cString(): string
Format the instance as W3C
stringtz(DateTimeZone|string $value): static
Alias for setTimezone()
DateTimeZone|string $value The DateTimeZone object or timezone name to use.
staticwasWithinLast(string|int $timeInterval): bool
Returns true this instance happened within the specified interval
string|int $timeInterval the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute.
boolyear(int $value): static
Set the instance's year
int $value The year value.
static
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/interface-Cake.I18n.I18nDateTimeInterface.html