Class Time
Extends the built-in DateTime class to provide handy methods and locale-aware formatting helpers
Constants
- 
          
          intDAYS_PER_WEEK ¶7
- 
          
          stringDEFAULT_TO_STRING_FORMAT ¶'Y-m-d H:i:s'Default format to use for __toString method when type juggling occurs. 
- 
          
          intFRIDAY ¶5
- 
          
          intHOURS_PER_DAY ¶24
- 
          
          intMINUTES_PER_HOUR ¶60
- 
          
          intMONDAY ¶1
- 
          
          intMONTHS_PER_QUARTER ¶3
- 
          
          intMONTHS_PER_YEAR ¶12
- 
          
          intSATURDAY ¶6
- 
          
          intSECONDS_PER_MINUTE ¶60
- 
          
          intSUNDAY ¶7
- 
          
          intTHURSDAY ¶4
- 
          
          intTUESDAY ¶2
- 
          
          stringUNIX_TIMESTAMP_FORMAT ¶'unixTimestampFormat'serialise the value as a Unix Timestamp 
- 
          
          intWEDNESDAY ¶3
- 
          
          intWEEKS_PER_YEAR ¶52
- 
          
          intYEARS_PER_CENTURY ¶100
- 
          
          intYEARS_PER_DECADE ¶10
Property Summary
- 
        $_formatters protected staticIntlDateFormatter[]In-memory cache of date formatters 
- 
        $_jsonEncodeFormat protected staticstring|array|intThe format to use when converting this object to JSON. 
- 
        $_lastErrors protected staticarrayHolds the last error generated by createFromFormat 
- 
        $_toStringFormat protected staticstring|array|intThe format to use when formatting a time using Cake\I18n\Time::i18nFormat()and__toString. This format is also used byparseDateTime().
- 
        $age public @property-readintdoes a diffInYears() with default parameters 
- 
        $day public @property-readint
- 
        $dayOfWeek public @property-readint1 (for Monday) through 7 (for Sunday) 
- 
        $dayOfWeekName public @property-readstring
- 
        $dayOfYear public @property-readint0 through 365 
- 
        $days protected staticarrayNames of days of the week. 
- 
        $daysInMonth public @property-readintnumber of days in the given month 
- 
        $defaultLocale protected staticstringThe default locale to be used for displaying formatted date strings. 
- 
        $diffFormatter protected staticCake\Chronos\DifferenceFormatterInterface|nullInstance of the diff formatting object. 
- 
        $dst public @property-readbooldaylight savings time indicator, true if DST, false otherwise 
- 
        $hour public @property-readint
- 
        $local public @property-readboolchecks if the timezone is local, true if local, false otherwise 
- 
        $micro public @property-readint
- 
        $microsecond public @property-readint
- 
        $minute public @property-readint
- 
        $month public @property-readint
- 
        $niceFormat public staticstring|array|intThe format to use when formatting a time using Cake\I18n\Time::nice()
- 
        $offset public @property-readintthe timezone offset in seconds from UTC 
- 
        $offsetHours public @property-readintthe timezone offset in hours from UTC 
- 
        $quarter public @property-readintthe quarter of this instance, 1 - 4 
- 
        $relativePattern protected staticstringRegex for relative period. 
- 
        $second public @property-readint
- 
        $timestamp public @property-readintseconds since the Unix Epoch 
- 
        $timezone public @property-readDateTimeZone|stringthe current timezone 
- 
        $timezoneName public @property-readstring
- 
        $toStringFormat protected staticstringFormat to use for __toString method when type juggling occurs. 
- 
        $tz public @property-readDateTimeZone|stringalias of timezone 
- 
        $tzName public @property-readstring
- 
        $utc public @property-readboolchecks if the timezone is UTC, true if UTC, false otherwise 
- 
        $weekEndsAt protected staticintLast day of week 
- 
        $weekOfMonth public @property-readint1 through 5 
- 
        $weekOfYear public @property-readintISO-8601 week number of year, weeks starting on Monday 
- 
        $weekStartsAt protected staticintFirst day of week 
- 
        $weekendDays protected staticarrayDays of weekend 
- 
        $wordAccuracy public staticstring[]The format to use when formatting a time using Time::timeAgoInWords()and the difference is less thanTime::$wordEnd
- 
        $wordEnd public staticstringThe end of relative time telling 
- 
        $wordFormat public staticstring|array|intThe format to use when formatting a time using Cake\I18n\Time::timeAgoInWords()and the difference is more thanCake\I18n\Time::$wordEnd
- 
        $year public @property-readint
- 
        $yearIso public @property-readint
Method Summary
- 
          __construct() publicCreate a new mutable time instance. 
- 
          __debugInfo() publicReturns the data that should be displayed when debugging this object 
- 
          __get() publicGet a part of the ChronosInterface object 
- 
          __isset() publicCheck if an attribute exists on the object 
- 
          __set() publicSet a part of the ChronosInterface object 
- 
          __toString() publicFormat the instance as a string using the set format 
- 
          _formatObject() protectedReturns a translated and localized date string. Implements what IntlDateFormatter::formatObject() is in PHP 5.5+ 
- 
          addDay() publicAdd a day to the instance 
- 
          addDays() publicAdd days to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addHour() publicAdd an hour to the instance 
- 
          addHours() publicAdd hours to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addMinute() publicAdd a minute to the instance 
- 
          addMinutes() publicAdd minutes to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addMonth() publicAdd a month to the instance. 
- 
          addMonthWithOverflow() publicAdd a month with overflow to the instance. 
- 
          addMonths() publicAdd months to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addMonthsWithOverflow() publicAdd months with overflowing to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addSecond() publicAdd a second to the instance 
- 
          addSeconds() publicAdd seconds to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addWeek() publicAdd a week to the instance 
- 
          addWeekday() publicAdd a weekday to the instance 
- 
          addWeekdays() publicAdd weekdays to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addWeeks() publicAdd weeks to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          addYear() publicAdd a year to the instance 
- 
          addYearWithOverflow() publicAdd a year with overflow to the instance 
- 
          addYears() publicAdd years to the instance. Positive $value travel forward while negative $value travel into the past. 
- 
          addYearsWithOverflow() publicAdd years with overflowing to the instance. Positive $value travels forward while negative $value travels into the past. 
- 
          average() publicModify the current instance to the average of a given instance (default now) and the current instance. 
- 
          between() publicDetermines if the instance is between two others 
- 
          closest() publicGet the closest date from the instance. 
- 
          copy() publicGet a copy of the instance 
- 
          create() public staticCreate a new ChronosInterface instance from a specific date and time. 
- 
          createFromArray() public staticCreates a ChronosInterface instance from an array of date and time values. 
- 
          createFromDate() public staticCreate a ChronosInterface instance from just a date. The time portion is set to now. 
- 
          createFromFormat() public staticCreate a ChronosInterface instance from a specific format 
- 
          createFromTime() public staticCreate a ChronosInterface instance from just a time. The date portion is set to today. 
- 
          createFromTimestamp() public staticCreate a ChronosInterface instance from a timestamp 
- 
          createFromTimestampUTC() public staticCreate a ChronosInterface instance from an UTC timestamp 
- 
          day() publicSet the instance's day 
- 
          diffFiltered() publicGet the difference by the given interval using a filter callable 
- 
          diffForHumans() publicGet the difference in a human readable format in the current locale. 
- 
          diffFormatter() public staticGet the difference formatter instance or overwrite the current one. 
- 
          diffInDays() publicGet the difference in days 
- 
          diffInDaysFiltered() publicGet the difference in days using a filter callable 
- 
          diffInHours() publicGet the difference in hours 
- 
          diffInHoursFiltered() publicGet the difference in hours using a filter callable 
- 
          diffInMinutes() publicGet the difference in minutes 
- 
          diffInMonths() publicGet the difference in months 
- 
          diffInMonthsIgnoreTimezone() publicGet the difference in months ignoring the timezone. This means the months are calculated in the specified timezone without converting to UTC first. This prevents the day from changing which can change the month. 
- 
          diffInSeconds() publicGet the difference in seconds 
- 
          diffInWeekdays() publicGet the difference in weekdays 
- 
          diffInWeekendDays() publicGet the difference in weekend days using a filter 
- 
          diffInWeeks() publicGet the difference in weeks 
- 
          diffInYears() publicGet the difference in years 
- 
          endOfCentury() publicSets the date to end of the century and time to 23:59:59 
- 
          endOfDay() publicSets the time to 23:59:59 or 23:59:59.999999 if $microsecondsis true.
- 
          endOfDecade() publicSets the date to end of the decade and time to 23:59:59 
- 
          endOfMonth() publicSets the date to end of the month and time to 23:59:59 
- 
          endOfWeek() publicSets the date to end of week (defined in $weekEndsAt) and time to 23:59:59 
- 
          endOfYear() publicSets the date to end of the year and time to 23:59:59 
- 
          eq() publicDetermines if the instance is equal to another 
- 
          equals() publicDetermines if the instance is equal to another 
- 
          farthest() publicGet the farthest date from the instance. 
- 
          firstOfMonth() publicModify 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. 
- 
          firstOfQuarter() publicModify 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. 
- 
          firstOfYear() publicModify 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. 
- 
          fromNow() public staticConvenience method for getting the remaining time from a given time. 
- 
          getDefaultLocale() public staticGets the default locale. 
- 
          getDiffFormatter() public staticGet the difference formatter instance. 
- 
          getLastErrors() public staticReturns any errors or warnings that were found during the parsing of the last object created by this class. 
- 
          getTestNow() public staticGet the test instance stored in Chronos 
- 
          getWeekEndsAt() public staticGet the last day of week 
- 
          getWeekStartsAt() public staticGet the first day of week 
- 
          getWeekendDays() public staticGet weekend days 
- 
          greaterThan() publicDetermines if the instance is greater (after) than another 
- 
          greaterThanOrEquals() publicDetermines if the instance is greater (after) than or equal to another 
- 
          gt() publicDetermines if the instance is greater (after) than another 
- 
          gte() publicDetermines if the instance is greater (after) than or equal to another 
- 
          hasRelativeKeywords() public staticDetermine if there is a relative keyword in the time string, this is to create dates relative to now for test instances. e.g.: next tuesday 
- 
          hasTestNow() public staticGet whether or not Chronos has a test instance set. 
- 
          hour() publicSet the instance's hour 
- 
          i18nFormat() publicReturns a formatted string for this time object using the preferred format and language for the specified locale. 
- 
          instance() public staticCreate a ChronosInterface instance from a DateTimeInterface one 
- 
          isBirthday() publicCheck if its the birthday. Compares the date/month values of the two dates. 
- 
          isFriday() publicChecks if this day is a Friday. 
- 
          isFuture() publicDetermines if the instance is in the future, ie. greater (after) than now 
- 
          isLastMonth() publicDetermines if the instance is within the last month 
- 
          isLastWeek() publicDetermines if the instance is within the last week 
- 
          isLastYear() publicDetermines if the instance is within the last year 
- 
          isLeapYear() publicDetermines if the instance is a leap year 
- 
          isMonday() publicChecks if this day is a Monday. 
- 
          isMutable() publicCheck if instance of ChronosInterface is mutable. 
- 
          isNextMonth() publicDetermines if the instance is within the next month 
- 
          isNextWeek() publicDetermines if the instance is within the next week 
- 
          isNextYear() publicDetermines if the instance is within the next year 
- 
          isPast() publicDetermines if the instance is in the past, ie. less (before) than now 
- 
          isSameDay() publicChecks if the passed in date is the same day as the instance current day. 
- 
          isSaturday() publicChecks if this day is a Saturday. 
- 
          isSunday() publicChecks if this day is a Sunday. 
- 
          isThisMonth() publicReturns true if this object represents a date within the current month 
- 
          isThisWeek() publicReturns true if this object represents a date within the current week 
- 
          isThisYear() publicReturns true if this object represents a date within the current year 
- 
          isThursday() publicChecks if this day is a Thursday. 
- 
          isToday() publicDetermines if the instance is today 
- 
          isTomorrow() publicDetermines if the instance is tomorrow 
- 
          isTuesday() publicChecks if this day is a Tuesday. 
- 
          isWednesday() publicChecks if this day is a Wednesday. 
- 
          isWeekday() publicDetermines if the instance is a weekday 
- 
          isWeekend() publicDetermines if the instance is a weekend day 
- 
          isWithinNext() publicReturns true this instance will happen within the specified interval 
- 
          isYesterday() publicDetermines if the instance is yesterday 
- 
          jsonSerialize() publicReturns a string that should be serialized when converting this object to json 
- 
          lastOfMonth() publicModify 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. 
- 
          lastOfQuarter() publicModify 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. 
- 
          lastOfYear() publicModify 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. 
- 
          lessThan() publicDetermines if the instance is less (before) than another 
- 
          lessThanOrEquals() publicDetermines if the instance is less (before) or equal to another 
- 
          listTimezones() public staticGet list of timezone identifiers 
- 
          lt() publicDetermines if the instance is less (before) than another 
- 
          lte() publicDetermines if the instance is less (before) or equal to another 
- 
          max() publicGet the maximum instance between a given instance (default now) and the current instance. 
- 
          maxValue() public staticCreate a ChronosInterface instance for the greatest supported date. 
- 
          microsecond() publicSet the instance's microsecond 
- 
          min() publicGet the minimum instance between a given instance (default now) and the current instance. 
- 
          minValue() public staticCreate a ChronosInterface instance for the lowest supported date. 
- 
          minute() publicSet the instance's minute 
- 
          modify() public @method
- 
          month() publicSet the instance's month 
- 
          ne() publicDetermines if the instance is not equal to another 
- 
          next() publicModify 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. 
- 
          nice() publicReturns a nicely formatted date string for this object. 
- 
          notEquals() publicDetermines if the instance is not equal to another 
- 
          now() public staticGet a ChronosInterface instance for the current date and time 
- 
          nthOfMonth() publicModify 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. 
- 
          nthOfQuarter() publicModify 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. 
- 
          nthOfYear() publicModify 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. 
- 
          parse() public staticCreate a ChronosInterface instance from a string. This is an alias for the constructor that allows better fluent syntax as it allows you to do ChronosInterface::parse('Monday next week')->fn() rather than (new Chronos('Monday next week'))->fn() 
- 
          parseDate() public staticReturns 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. 
- 
          parseDateTime() public staticReturns 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. 
- 
          parseTime() public staticReturns 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. 
- 
          previous() publicModify 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. 
- 
          resetToStringFormat() public staticResets the format used to the default when converting an instance of this type to a string 
- 
          safeCreateDateTimeZone() protected staticCreates a DateTimeZone from a string or a DateTimeZone 
- 
          second() publicSet the instance's second 
- 
          secondsSinceMidnight() publicThe number of seconds since midnight. 
- 
          secondsUntilEndOfDay() publicThe number of seconds until 23:59:59. 
- 
          setDate() publicSet the date to a different date. 
- 
          setDateTime() publicSet the date and time all together 
- 
          setDefaultLocale() public staticSets the default locale. 
- 
          setDiffFormatter() public staticSet the difference formatter instance. 
- 
          setJsonEncodeFormat() public staticSets the default format used when converting this object to json 
- 
          setTestNow() public staticSet the test now used by Date and Time classes provided by Chronos 
- 
          setTimeFromTimeString() publicSet the time by time string 
- 
          setTimezone() publicSet the instance's timezone from a string or object 
- 
          setToStringFormat() public staticSets the default format used when type converting instances of this type to string 
- 
          setWeekEndsAt() public staticSet the last day of week 
- 
          setWeekStartsAt() public staticSet the first day of week 
- 
          setWeekendDays() public staticSet weekend days 
- 
          startOfCentury() publicSets the date to the first day of the century and the time to 00:00:00 
- 
          startOfDay() publicSets the time to 00:00:00 
- 
          startOfDecade() publicSets the date to the first day of the decade and the time to 00:00:00 
- 
          startOfMonth() publicSets the date to the first day of the month and the time to 00:00:00 
- 
          startOfWeek() publicSets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00 
- 
          startOfYear() publicSets the date to the first day of the year and the time to 00:00:00 
- 
          subDay() publicRemove a day from the instance 
- 
          subDays() publicRemove days from the instance 
- 
          subHour() publicRemove an hour from the instance 
- 
          subHours() publicRemove hours from the instance 
- 
          subMinute() publicRemove a minute from the instance 
- 
          subMinutes() publicRemove minutes from the instance 
- 
          subMonth() publicRemove a month from the instance 
- 
          subMonthWithOverflow() publicRemove a month with overflow from the instance. 
- 
          subMonths() publicRemove months from the instance. 
- 
          subMonthsWithOverflow() publicRemove months with overflow from the instance. 
- 
          subSecond() publicRemove a second from the instance 
- 
          subSeconds() publicRemove seconds from the instance 
- 
          subWeek() publicRemove a week from the instance 
- 
          subWeekday() publicRemove a weekday from the instance 
- 
          subWeekdays() publicRemove weekdays from the instance 
- 
          subWeeks() publicRemove weeks to the instance 
- 
          subYear() publicRemove a year from the instance. 
- 
          subYearWithOverflow() publicRemove a year with overflow from the instance 
- 
          subYears() publicRemove years from the instance. 
- 
          subYearsWithOverflow() publicRemove years with overflow from the instance 
- 
          timeAgoInWords() publicReturns either a relative or a formatted absolute date depending on the difference between the current time and this object. 
- 
          timestamp() publicSet the instance's timestamp 
- 
          timezone() publicAlias for setTimezone() 
- 
          toAtomString() publicFormat the instance as ATOM 
- 
          toCookieString() publicFormat the instance as COOKIE 
- 
          toDateString() publicFormat the instance as date 
- 
          toDateTimeString() publicFormat the instance as date and time 
- 
          toDayDateTimeString() publicFormat the instance with day, date and time 
- 
          toFormattedDateString() publicFormat the instance as a readable date 
- 
          toImmutable() publicCreate a new immutable instance from current mutable instance. 
- 
          toIso8601String() publicFormat the instance as ISO8601 
- 
          toQuarter() publicReturns the quarter 
- 
          toRfc1036String() publicFormat the instance as RFC1036 
- 
          toRfc1123String() publicFormat the instance as RFC1123 
- 
          toRfc2822String() publicFormat the instance as RFC2822 
- 
          toRfc3339String() publicFormat the instance as RFC3339 
- 
          toRfc822String() publicFormat the instance as RFC822 
- 
          toRfc850String() publicFormat the instance as RFC850 
- 
          toRssString() publicFormat the instance as RSS 
- 
          toTimeString() publicFormat the instance as time 
- 
          toUnixString() publicReturns a UNIX timestamp. 
- 
          toW3cString() publicFormat the instance as W3C 
- 
          toWeek() public
- 
          today() public staticCreate a ChronosInterface instance for today 
- 
          tomorrow() public staticCreate a ChronosInterface instance for tomorrow 
- 
          tz() publicAlias for setTimezone() 
- 
          wasWithinLast() publicReturns true this instance happened within the specified interval 
- 
          year() publicSet the instance's year 
- 
          yesterday() public staticCreate a ChronosInterface instance for yesterday 
Method Detail
__construct() ¶ public
__construct(DateTimeInterface|string|int|null $time = null, DateTimeZone|string|null $tz = null)Create a new mutable time instance.
Please see the testing aids section (specifically static::setTestNow()) for more on the possibility of this constructor returning a test instance.
Parameters
- 
                DateTimeInterface|string|int|null$time optional
- Fixed or relative time 
- 
                DateTimeZone|string|null$tz optional
- The timezone for the instance 
__debugInfo() ¶ public
__debugInfo(): arrayReturns the data that should be displayed when debugging this object
Returns
array__get() ¶ public
__get(string $name): string|int|bool|DateTimeZoneGet a part of the ChronosInterface object
Parameters
- 
                string$name
- The property name to read. 
Returns
string|int|bool|DateTimeZoneThe property value.
Throws
InvalidArgumentException__isset() ¶ public
__isset(string $name): boolCheck if an attribute exists on the object
Parameters
- 
                string$name
- The property name to check. 
Returns
boolWhether or not the property exists.
__set() ¶ public
__set(string $name, string|int|DateTimeZone $value): voidSet a part of the ChronosInterface object
Parameters
- 
                string$name
- The property to set. 
- 
                string|int|DateTimeZone$value
- The value to set. 
Returns
voidThrows
InvalidArgumentException__toString() ¶ public
__toString(): stringFormat the instance as a string using the set format
Returns
string_formatObject() ¶ protected
_formatObject(DateTime|DateTimeImmutable $date, string|int|array $format, string|null $locale): stringReturns a translated and localized date string. Implements what IntlDateFormatter::formatObject() is in PHP 5.5+
Parameters
- 
                DateTime|DateTimeImmutable$date
- Date. 
- 
                string|int|array$format
- Format. 
- 
                string|null$locale
- The locale name in which the date should be displayed. 
Returns
stringaddDay() ¶ public
addDay(int $value = 1): staticAdd a day to the instance
Parameters
- 
                int$value optional
- The number of days to add. 
Returns
staticaddDays() ¶ public
addDays(int $value): staticAdd days to the instance. Positive $value travels forward while negative $value travels into the past.
Parameters
- 
                int$value
- The number of days to add. 
Returns
staticaddHour() ¶ public
addHour(int $value = 1): staticAdd an hour to the instance
Parameters
- 
                int$value optional
- The number of hours to add. 
Returns
staticaddHours() ¶ public
addHours(int $value): staticAdd hours to the instance. Positive $value travels forward while negative $value travels into the past.
Parameters
- 
                int$value
- The number of hours to add. 
Returns
staticaddMinute() ¶ public
addMinute(int $value = 1): staticAdd a minute to the instance
Parameters
- 
                int$value optional
- The number of minutes to add. 
Returns
staticaddMinutes() ¶ public
addMinutes(int $value): staticAdd minutes to the instance. Positive $value travels forward while negative $value travels into the past.
Parameters
- 
                int$value
- The number of minutes to add. 
Returns
staticaddMonth() ¶ public
addMonth(int $value = 1): staticAdd a month to the instance.
Has the same behavior as addMonths().
Parameters
- 
                int$value optional
- The number of months to add. 
Returns
staticaddMonthWithOverflow() ¶ public
addMonthWithOverflow(int $value = 1): staticAdd a month with overflow to the instance.
Has the same behavior as addMonthsWithOverflow().
Parameters
- 
                int$value optional
- The number of months to add. 
Returns
staticaddMonths() ¶ public
addMonths(int $value): staticAdd 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.
Example:
 (new Chronos('2015-01-03'))->addMonths(1); // Results in 2015-02-03
(new Chronos('2015-01-31'))->addMonths(1); // Results in 2015-02-28Parameters
- 
                int$value
- The number of months to add. 
Returns
staticaddMonthsWithOverflow() ¶ public
addMonthsWithOverflow(int $value): staticAdd 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.
Example:
 (new Chronos('2012-01-30'))->addMonthsWithOverflow(1); // Results in 2013-03-01Parameters
- 
                int$value
- The number of months to add. 
Returns
staticaddSecond() ¶ public
addSecond(int $value = 1): staticAdd a second to the instance
Parameters
- 
                int$value optional
- The number of seconds to add. 
Returns
staticaddSeconds() ¶ public
addSeconds(int $value): staticAdd seconds to the instance. Positive $value travels forward while negative $value travels into the past.
Parameters
- 
                int$value
- The number of seconds to add. 
Returns
staticaddWeek() ¶ public
addWeek(int $value = 1): staticAdd a week to the instance
Parameters
- 
                int$value optional
- The number of weeks to add. 
Returns
staticaddWeekday() ¶ public
addWeekday(int $value = 1): staticAdd a weekday to the instance
Parameters
- 
                int$value optional
- The number of weekdays to add. 
Returns
staticaddWeekdays() ¶ public
addWeekdays(int $value): staticAdd weekdays to the instance. Positive $value travels forward while negative $value travels into the past.
Parameters
- 
                int$value
- The number of weekdays to add. 
Returns
staticaddWeeks() ¶ public
addWeeks(int $value): staticAdd weeks to the instance. Positive $value travels forward while negative $value travels into the past.
Parameters
- 
                int$value
- The number of weeks to add. 
Returns
staticaddYear() ¶ public
addYear(int $value = 1): staticAdd a year to the instance
Has the same behavior as addYears().
Parameters
- 
                int$value optional
- The number of years to add. 
Returns
staticaddYearWithOverflow() ¶ public
addYearWithOverflow(int $value = 1): staticAdd a year with overflow to the instance
Has the same behavior as addYearsWithOverflow().
Parameters
- 
                int$value optional
- The number of years to add. 
Returns
staticaddYears() ¶ public
addYears(int $value): staticAdd 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.
Example:
 (new Chronos('2015-01-03'))->addYears(1); // Results in 2016-01-03
(new Chronos('2012-02-29'))->addYears(1); // Results in 2013-02-28Parameters
- 
                int$value
- The number of years to add. 
Returns
staticaddYearsWithOverflow() ¶ public
addYearsWithOverflow(int $value): staticAdd 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.
Example:
 (new Chronos('2012-02-29'))->addYearsWithOverflow(1); // Results in 2013-03-01Parameters
- 
                int$value
- The number of years to add. 
Returns
staticaverage() ¶ public
average(Cake\Chronos\ChronosInterface $dt = null): staticModify the current instance to the average of a given instance (default now) and the current instance.
Parameters
- 
                Cake\Chronos\ChronosInterface$dt optional
- The instance to compare with. 
Returns
staticbetween() ¶ public
between(Cake\Chronos\ChronosInterface $dt1, Cake\Chronos\ChronosInterface $dt2, bool $equal = true): boolDetermines 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. 
- 
                bool$equal optional
- Indicates if a > and < comparison should be used or <= or >= 
Returns
boolclosest() ¶ public
closest(Cake\Chronos\ChronosInterface $dt1, Cake\Chronos\ChronosInterface $dt2): staticGet 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
staticcreate() ¶ public static
create(int|null $year = null, int|null $month = null, int|null $day = null, int|null $hour = null, int|null $minute = null, int|null $second = null, int|null $microsecond = null, DateTimeZone|string|null $tz = null): staticCreate a new ChronosInterface instance from a specific date and time.
If any of $year, $month or $day are set to null their now() values will be used.
If $hour is null it will be set to its now() value and the default values for $minute, $second and $microsecond will be their now() values. If $hour is not null then the default values for $minute, $second and $microsecond will be 0.
Parameters
- 
                int|null$year optional
- The year to create an instance with. 
- 
                int|null$month optional
- The month to create an instance with. 
- 
                int|null$day optional
- The day to create an instance with. 
- 
                int|null$hour optional
- The hour to create an instance with. 
- 
                int|null$minute optional
- The minute to create an instance with. 
- 
                int|null$second optional
- The second to create an instance with. 
- 
                int|null$microsecond optional
- The microsecond to create an instance with. 
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
staticcreateFromArray() ¶ public static
createFromArray((int|string)[] $values): staticCreates a ChronosInterface instance from an array of date and time values.
The 'year', 'month' and 'day' values must all be set for a date. The time values all default to 0.
The 'timezone' value can be any format supported by \DateTimeZone.
Allowed values:
- year
- month
- day
- hour
- minute
- second
- microsecond
- meridian ('am' or 'pm')
- timezone
Parameters
- 
                (int|string)[]$values
- Array of date and time values. 
Returns
staticcreateFromDate() ¶ public static
createFromDate(int|null $year = null, int|null $month = null, int|null $day = null, DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance from just a date. The time portion is set to now.
Parameters
- 
                int|null$year optional
- The year to create an instance with. 
- 
                int|null$month optional
- The month to create an instance with. 
- 
                int|null$day optional
- The day to create an instance with. 
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
staticcreateFromFormat() ¶ public static
createFromFormat(string $format, string $time, DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance from a specific format
Parameters
- 
                string$format
- The date() compatible format string. 
- 
                string$time
- The formatted date string to interpret. 
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
staticThrows
InvalidArgumentExceptioncreateFromTime() ¶ public static
createFromTime(int|null $hour = null, int|null $minute = null, int|null $second = null, int|null $microsecond = null, DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance from just a time. The date portion is set to today.
Parameters
- 
                int|null$hour optional
- The hour to create an instance with. 
- 
                int|null$minute optional
- The minute to create an instance with. 
- 
                int|null$second optional
- The second to create an instance with. 
- 
                int|null$microsecond optional
- The microsecond to create an instance with. 
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
staticcreateFromTimestamp() ¶ public static
createFromTimestamp(float|int $timestamp, DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance from a timestamp
Parameters
- 
                float|int$timestamp
- The timestamp to create an instance from. 
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
staticcreateFromTimestampUTC() ¶ public static
createFromTimestampUTC(int $timestamp): staticCreate a ChronosInterface instance from an UTC timestamp
Parameters
- 
                int$timestamp
- The UTC timestamp to create an instance from. 
Returns
staticday() ¶ public
day(int $value): staticSet the instance's day
Parameters
- 
                int$value
- The day value. 
Returns
staticdiffFiltered() ¶ public
diffFiltered(Cake\Chronos\ChronosInterval $ci, callable $callback, Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet 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 optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffForHumans() ¶ public
diffForHumans(Cake\Chronos\ChronosInterface|null $other = null, bool $absolute = false): stringGet 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 optional
- The datetime to compare with. 
- 
                bool$absolute optional
- Removes time difference modifiers ago, after, etc 
Returns
stringdiffFormatter() ¶ public static
diffFormatter(Cake\Chronos\DifferenceFormatterInterface|null $formatter = null): Cake\Chronos\DifferenceFormatterInterfaceGet the difference formatter instance or overwrite the current one.
Parameters
- 
                Cake\Chronos\DifferenceFormatterInterface|null$formatter optional
- The formatter instance when setting. 
Returns
Cake\Chronos\DifferenceFormatterInterfaceThe formatter instance.
diffInDays() ¶ public
diffInDays(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in days
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInDaysFiltered() ¶ public
diffInDaysFiltered(callable $callback, Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in days using a filter callable
Parameters
- 
                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 
Returns
intdiffInHours() ¶ public
diffInHours(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in hours
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInHoursFiltered() ¶ public
diffInHoursFiltered(callable $callback, Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in hours using a filter callable
Parameters
- 
                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 
Returns
intdiffInMinutes() ¶ public
diffInMinutes(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in minutes
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInMonths() ¶ public
diffInMonths(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in months
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInMonthsIgnoreTimezone() ¶ public
diffInMonthsIgnoreTimezone(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in months ignoring the timezone. This means the months are calculated in the specified timezone without converting to UTC first. This prevents the day from changing which can change the month.
For example, if comparing 2019-06-01 Asia/Tokyo and 2019-10-01 Asia/Tokyo,
the result would be 4 months instead of 3 when using normal DateTime::diff().
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInSeconds() ¶ public
diffInSeconds(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in seconds
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInWeekdays() ¶ public
diffInWeekdays(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in weekdays
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInWeekendDays() ¶ public
diffInWeekendDays(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in weekend days using a filter
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInWeeks() ¶ public
diffInWeeks(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in weeks
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intdiffInYears() ¶ public
diffInYears(Cake\Chronos\ChronosInterface|null $dt = null, bool $abs = true): intGet the difference in years
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to difference from. 
- 
                bool$abs optional
- Get the absolute of the difference 
Returns
intendOfCentury() ¶ public
endOfCentury(): staticSets the date to end of the century and time to 23:59:59
Returns
staticendOfDay() ¶ public
endOfDay(bool $microseconds = false): staticSets the time to 23:59:59 or 23:59:59.999999
if $microseconds is true.
Parameters
- 
                bool$microseconds optional
- Whether to set microseconds 
Returns
staticendOfDecade() ¶ public
endOfDecade(): staticSets the date to end of the decade and time to 23:59:59
Returns
staticendOfMonth() ¶ public
endOfMonth(): staticSets the date to end of the month and time to 23:59:59
Returns
staticendOfWeek() ¶ public
endOfWeek(): staticSets the date to end of week (defined in $weekEndsAt) and time to 23:59:59
Returns
staticendOfYear() ¶ public
endOfYear(): staticSets the date to end of the year and time to 23:59:59
Returns
staticeq() ¶ public
eq(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolSee Also
equals() ¶ public
equals(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolfarthest() ¶ public
farthest(Cake\Chronos\ChronosInterface $dt1, Cake\Chronos\ChronosInterface $dt2): staticGet 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
staticfirstOfMonth() ¶ public
firstOfMonth(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticfirstOfQuarter() ¶ public
firstOfQuarter(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticfirstOfYear() ¶ public
firstOfYear(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticfromNow() ¶ public static
fromNow(DateTime|DateTimeImmutable $datetime): DateInterval|boolConvenience method for getting the remaining time from a given time.
Parameters
- 
                DateTime|DateTimeImmutable$datetime
- The date to get the remaining time from. 
Returns
DateInterval|boolThe DateInterval object representing the difference between the two dates or FALSE on failure.
getDefaultLocale() ¶ public static
getDefaultLocale(): string|nullGets the default locale.
Returns
string|nullThe default locale string to be used or null.
getDiffFormatter() ¶ public static
getDiffFormatter(): Cake\Chronos\DifferenceFormatterInterfaceGet the difference formatter instance.
Returns
Cake\Chronos\DifferenceFormatterInterfacegetLastErrors() ¶ public static
getLastErrors(): arrayReturns any errors or warnings that were found during the parsing of the last object created by this class.
Returns
arraygetTestNow() ¶ public static
getTestNow(): Cake\Chronos\ChronosInterface|nullGet the test instance stored in Chronos
Returns
Cake\Chronos\ChronosInterface|nullthe current instance used for testing or null.
See Also
greaterThan() ¶ public
greaterThan(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is greater (after) than another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolgreaterThanOrEquals() ¶ public
greaterThanOrEquals(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is greater (after) than or equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolgt() ¶ public
gt(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is greater (after) than another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolSee Also
gte() ¶ public
gte(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is greater (after) than or equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolSee Also
hasRelativeKeywords() ¶ public static
hasRelativeKeywords(string|null $time): boolDetermine if there is a relative keyword in the time string, this is to create dates relative to now for test instances. e.g.: next tuesday
Parameters
- 
                string|null$time
- The time string to check. 
Returns
booltrue if there is a keyword, otherwise false
hasTestNow() ¶ public static
hasTestNow(): boolGet whether or not Chronos has a test instance set.
Returns
boolTrue if there is a test instance, otherwise false
See Also
hour() ¶ public
hour(int $value): staticSet the instance's hour
Parameters
- 
                int$value
- The hour value. 
Returns
statici18nFormat() ¶ public
i18nFormat(string|int|null $format = null, string|DateTimeZone|null $timezone = null, string|null $locale = null): string|intReturns 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: http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details.
Additional to IntlDateFormatter constants and date formatting string you can use
Time::UNIX_TIMESTAMP_FORMAT to get a unix timestamp
Examples
$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'You can control the default format used through Time::setToStringFormat().
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.
Examples
$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 used through Time::setDefaultLocale().
If empty, the default will be taken from the intl.default_locale ini config.
Parameters
- 
                string|int|null$format optional
- Format string. 
- 
                string|DateTimeZone|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) 
Returns
string|intFormatted and translated date string
instance() ¶ public static
instance(DateTimeInterface $dt): staticCreate a ChronosInterface instance from a DateTimeInterface one
Parameters
- 
                DateTimeInterface$dt
- The datetime instance to convert. 
Returns
staticisBirthday() ¶ public
isBirthday(Cake\Chronos\ChronosInterface $dt): boolCheck if its the birthday. Compares the date/month values of the two dates.
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolisFuture() ¶ public
isFuture(): boolDetermines if the instance is in the future, ie. greater (after) than now
Returns
boolisLastMonth() ¶ public
isLastMonth(): boolDetermines if the instance is within the last month
Returns
boolisLastWeek() ¶ public
isLastWeek(): boolDetermines if the instance is within the last week
Returns
boolisLastYear() ¶ public
isLastYear(): boolDetermines if the instance is within the last year
Returns
boolisMutable() ¶ public
isMutable(): boolCheck if instance of ChronosInterface is mutable.
Returns
boolisNextMonth() ¶ public
isNextMonth(): boolDetermines if the instance is within the next month
Returns
boolisNextWeek() ¶ public
isNextWeek(): boolDetermines if the instance is within the next week
Returns
boolisNextYear() ¶ public
isNextYear(): boolDetermines if the instance is within the next year
Returns
boolisPast() ¶ public
isPast(): boolDetermines if the instance is in the past, ie. less (before) than now
Returns
boolisSameDay() ¶ public
isSameDay(Cake\Chronos\ChronosInterface $dt): boolChecks 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
boolisThisMonth() ¶ public
isThisMonth(): boolReturns true if this object represents a date within the current month
Returns
boolisThisWeek() ¶ public
isThisWeek(): boolReturns true if this object represents a date within the current week
Returns
boolisThisYear() ¶ public
isThisYear(): boolReturns true if this object represents a date within the current year
Returns
boolisWithinNext() ¶ public
isWithinNext(string|int $timeInterval): boolReturns true this instance will happen within the specified interval
Parameters
- 
                string|int$timeInterval
- the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute. 
Returns
booljsonSerialize() ¶ public
jsonSerialize(): string|intReturns a string that should be serialized when converting this object to json
Returns
string|intlastOfMonth() ¶ public
lastOfMonth(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticlastOfQuarter() ¶ public
lastOfQuarter(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticlastOfYear() ¶ public
lastOfYear(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticlessThan() ¶ public
lessThan(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is less (before) than another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boollessThanOrEquals() ¶ public
lessThanOrEquals(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is less (before) or equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boollistTimezones() ¶ public static
listTimezones(int|string|null $filter = null, string|null $country = null, bool|array $options = []): arrayGet list of timezone identifiers
Parameters
- 
                int|string|null$filter optional
- A regex to filter identifier Or one of DateTimeZone class constants 
- 
                string|null$country optional
- A two-letter ISO 3166-1 compatible country code. This option is only used when $filter is set to DateTimeZone::PER_COUNTRY 
- 
                bool|array$options optional
- If true (default value) groups the identifiers list by primary region. Otherwise, an array containing - group,- abbr,- before, and- afterkeys. Setting- groupand- abbrto true will group results and append timezone abbreviation in the display value. Set- beforeand- afterto customize the abbreviation wrapper.
Returns
arrayList of timezone identifiers
lt() ¶ public
lt(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is less (before) than another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolSee Also
lte() ¶ public
lte(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is less (before) or equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolSee Also
max() ¶ public
max(Cake\Chronos\ChronosInterface|null $dt = null): staticGet the maximum instance between a given instance (default now) and the current instance.
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to compare with. 
Returns
staticmaxValue() ¶ public static
maxValue(): Cake\Chronos\ChronosInterfaceCreate a ChronosInterface instance for the greatest supported date.
Returns
Cake\Chronos\ChronosInterfacemicrosecond() ¶ public
microsecond(int $value): staticSet the instance's microsecond
Parameters
- 
                int$value
- The microsecond value. 
Returns
staticmin() ¶ public
min(Cake\Chronos\ChronosInterface|null $dt = null): staticGet the minimum instance between a given instance (default now) and the current instance.
Parameters
- 
                Cake\Chronos\ChronosInterface|null$dt optional
- The instance to compare with. 
Returns
staticminValue() ¶ public static
minValue(): Cake\Chronos\ChronosInterfaceCreate a ChronosInterface instance for the lowest supported date.
Returns
Cake\Chronos\ChronosInterfaceminute() ¶ public
minute(int $value): staticSet the instance's minute
Parameters
- 
                int$value
- The minute value. 
Returns
staticmodify() ¶ public @method
modify(string $relative): Cake\Chronos\ChronosInterfaceParameters
- 
                string$relative
Returns
Cake\Chronos\ChronosInterfacemonth() ¶ public
month(int $value): staticSet the instance's month
Parameters
- 
                int$value
- The month value. 
Returns
staticne() ¶ public
ne(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is not equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolSee Also
next() ¶ public
next(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticnice() ¶ public
nice(string|DateTimeZone|null $timezone = null, string|null $locale = null): stringReturns a nicely formatted date string for this object.
The format to be used is stored in the static property Time::niceFormat.
Parameters
- 
                string|DateTimeZone|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) 
Returns
stringFormatted date string
notEquals() ¶ public
notEquals(Cake\Chronos\ChronosInterface $dt): boolDetermines if the instance is not equal to another
Parameters
- 
                Cake\Chronos\ChronosInterface$dt
- The instance to compare with. 
Returns
boolnow() ¶ public static
now(DateTimeZone|string|null $tz = null): staticGet a ChronosInterface instance for the current date and time
Parameters
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name. 
Returns
staticnthOfMonth() ¶ public
nthOfMonth(int $nth, int $dayOfWeek): static|falseModify 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
- 
                int$nth
- The offset to use. 
- 
                int$dayOfWeek
- The day of the week to move to. 
Returns
static|falsenthOfQuarter() ¶ public
nthOfQuarter(int $nth, int $dayOfWeek): static|falseModify 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
- 
                int$nth
- The offset to use. 
- 
                int$dayOfWeek
- The day of the week to move to. 
Returns
static|falsenthOfYear() ¶ public
nthOfYear(int $nth, int $dayOfWeek): static|falseModify 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
- 
                int$nth
- The offset to use. 
- 
                int$dayOfWeek
- The day of the week to move to. 
Returns
static|falseparse() ¶ public static
parse(DateTimeInterface|string|int $time = 'now', DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance from a string. This is an alias for the constructor that allows better fluent syntax as it allows you to do ChronosInterface::parse('Monday next week')->fn() rather than (new Chronos('Monday next week'))->fn()
Parameters
- 
                DateTimeInterface|string|int$time optional
- The strtotime compatible string to parse 
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name. 
Returns
staticparseDate() ¶ public static
parseDate(string $date, string|int|array|null $format = null): static|nullReturns 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);Parameters
- 
                string$date
- The date string to parse. 
- 
                string|int|array|null$format optional
- Any format accepted by IntlDateFormatter. 
Returns
static|nullparseDateTime() ¶ public static
parseDateTime(string $time, string|int[]|null $format = null, DateTimeZone|string|null $tz = null): static|nullReturns 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.
Unlike DateTime, the time zone of the returned instance is always converted
to $tz (default time zone if null) even if the $time string specified a
time zone. This is a limitation of IntlDateFormatter.
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]);Parameters
- 
                string$time
- The time string to parse. 
- 
                string|int[]|null$format optional
- Any format accepted by IntlDateFormatter. 
- 
                DateTimeZone|string|null$tz optional
- The timezone for the instance 
Returns
static|nullThrows
InvalidArgumentExceptionIf $format is a single int instead of array of constants
parseTime() ¶ public static
parseTime(string $time, string|int|null $format = null): static|nullReturns 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');Parameters
- 
                string$time
- The time string to parse. 
- 
                string|int|null$format optional
- Any format accepted by IntlDateFormatter. 
Returns
static|nullprevious() ¶ public
previous(int|null $dayOfWeek = null): staticModify 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
- 
                int|null$dayOfWeek optional
- The day of the week to move to. 
Returns
staticresetToStringFormat() ¶ public static
resetToStringFormat(): voidResets the format used to the default when converting an instance of this type to a string
Returns
voidsafeCreateDateTimeZone() ¶ protected static
safeCreateDateTimeZone(DateTimeZone|string|null $object): DateTimeZoneCreates a DateTimeZone from a string or a DateTimeZone
Parameters
- 
                DateTimeZone|string|null$object
- The value to convert. 
Returns
DateTimeZoneThrows
InvalidArgumentExceptionsecond() ¶ public
second(int $value): staticSet the instance's second
Parameters
- 
                int$value
- The seconds value. 
Returns
staticsecondsSinceMidnight() ¶ public
secondsSinceMidnight(): intThe number of seconds since midnight.
Returns
intsecondsUntilEndOfDay() ¶ public
secondsUntilEndOfDay(): intThe number of seconds until 23:59:59.
Returns
intsetDate() ¶ public
setDate(int $year, int $month, int $day): staticSet the date to a different date.
Workaround for a PHP bug related to the first day of a month
Parameters
- 
                int$year
- The year to set. 
- 
                int$month
- The month to set. 
- 
                int$day
- The day to set. 
Returns
staticsetDateTime() ¶ public
setDateTime(int $year, int $month, int $day, int $hour, int $minute, int $second = 0): staticSet the date and time all together
Parameters
- 
                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. 
Returns
staticsetDefaultLocale() ¶ public static
setDefaultLocale(string|null $locale = null): voidSets the default locale.
Parameters
- 
                string|null$locale optional
- The default locale string to be used or null. 
Returns
voidsetDiffFormatter() ¶ public static
setDiffFormatter(Cake\Chronos\DifferenceFormatterInterface $formatter): voidSet the difference formatter instance.
Parameters
- 
                Cake\Chronos\DifferenceFormatterInterface$formatter
- The formatter instance when setting. 
Returns
voidsetJsonEncodeFormat() ¶ public static
setJsonEncodeFormat(string|array|int $format): voidSets 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 (http://www.icu-project.org/apiref/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.
Parameters
- 
                string|array|int$format
- Format. 
Returns
voidSee Also
setTestNow() ¶ public static
setTestNow(Cake\Chronos\ChronosInterface|string|null $testNow = null): voidSet the test now used by Date and Time classes provided by Chronos
Parameters
- 
                Cake\Chronos\ChronosInterface|string|null$testNow optional
- The instance to use for all future instances. 
Returns
voidSee Also
setTimeFromTimeString() ¶ public
setTimeFromTimeString(string $time): staticSet the time by time string
Parameters
- 
                string$time
- Time as string. 
Returns
staticsetTimezone() ¶ public
setTimezone(DateTimeZone|string $value): staticSet the instance's timezone from a string or object
Parameters
- 
                DateTimeZone|string$value
- The DateTimeZone object or timezone name to use. 
Returns
staticsetToStringFormat() ¶ public static
setToStringFormat(string $format): voidSets the default format used when type converting instances of this type to string
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 (http://www.icu-project.org/apiref/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.
Parameters
- 
                string$format
- Format. 
Returns
voidsetWeekEndsAt() ¶ public static
setWeekEndsAt(int $day): voidSet the last day of week
Parameters
- 
                int$day
- The day the week ends with. 
Returns
voidsetWeekStartsAt() ¶ public static
setWeekStartsAt(int $day): voidSet the first day of week
Parameters
- 
                int$day
- The day the week starts with. 
Returns
voidsetWeekendDays() ¶ public static
setWeekendDays(array $days): voidSet weekend days
Parameters
- 
                array$days
- Which days are 'weekends'. 
Returns
voidstartOfCentury() ¶ public
startOfCentury(): staticSets the date to the first day of the century and the time to 00:00:00
Returns
staticstartOfDecade() ¶ public
startOfDecade(): staticSets the date to the first day of the decade and the time to 00:00:00
Returns
staticstartOfMonth() ¶ public
startOfMonth(): staticSets the date to the first day of the month and the time to 00:00:00
Returns
staticstartOfWeek() ¶ public
startOfWeek(): staticSets the date to the first day of week (defined in $weekStartsAt) and the time to 00:00:00
Returns
staticstartOfYear() ¶ public
startOfYear(): staticSets the date to the first day of the year and the time to 00:00:00
Returns
staticsubDay() ¶ public
subDay(int $value = 1): staticRemove a day from the instance
Parameters
- 
                int$value optional
- The number of days to remove. 
Returns
staticsubDays() ¶ public
subDays(int $value): staticRemove days from the instance
Parameters
- 
                int$value
- The number of days to remove. 
Returns
staticsubHour() ¶ public
subHour(int $value = 1): staticRemove an hour from the instance
Parameters
- 
                int$value optional
- The number of hours to remove. 
Returns
staticsubHours() ¶ public
subHours(int $value): staticRemove hours from the instance
Parameters
- 
                int$value
- The number of hours to remove. 
Returns
staticsubMinute() ¶ public
subMinute(int $value = 1): staticRemove a minute from the instance
Parameters
- 
                int$value optional
- The number of minutes to remove. 
Returns
staticsubMinutes() ¶ public
subMinutes(int $value): staticRemove minutes from the instance
Parameters
- 
                int$value
- The number of minutes to remove. 
Returns
staticsubMonth() ¶ public
subMonth(int $value = 1): staticRemove a month from the instance
Has the same behavior as addMonths().
Parameters
- 
                int$value optional
- The number of months to remove. 
Returns
staticsubMonthWithOverflow() ¶ public
subMonthWithOverflow(int $value = 1): staticRemove a month with overflow from the instance.
Has the same behavior as addMonthsWithOverflow().
Parameters
- 
                int$value optional
- The number of months to remove. 
Returns
staticsubMonths() ¶ public
subMonths(int $value): staticRemove months from the instance.
Has the same behavior as addMonths().
Parameters
- 
                int$value
- The number of months to remove. 
Returns
staticsubMonthsWithOverflow() ¶ public
subMonthsWithOverflow(int $value): staticRemove months with overflow from the instance.
Has the same behavior as addMonthsWithOverflow().
Parameters
- 
                int$value
- The number of months to remove. 
Returns
staticsubSecond() ¶ public
subSecond(int $value = 1): staticRemove a second from the instance
Parameters
- 
                int$value optional
- The number of seconds to remove. 
Returns
staticsubSeconds() ¶ public
subSeconds(int $value): staticRemove seconds from the instance
Parameters
- 
                int$value
- The number of seconds to remove. 
Returns
staticsubWeek() ¶ public
subWeek(int $value = 1): staticRemove a week from the instance
Parameters
- 
                int$value optional
- The number of weeks to remove. 
Returns
staticsubWeekday() ¶ public
subWeekday(int $value = 1): staticRemove a weekday from the instance
Parameters
- 
                int$value optional
- The number of weekdays to remove. 
Returns
staticsubWeekdays() ¶ public
subWeekdays(int $value): staticRemove weekdays from the instance
Parameters
- 
                int$value
- The number of weekdays to remove. 
Returns
staticsubWeeks() ¶ public
subWeeks(int $value): staticRemove weeks to the instance
Parameters
- 
                int$value
- The number of weeks to remove. 
Returns
staticsubYear() ¶ public
subYear(int $value = 1): staticRemove a year from the instance.
Has the same behavior as addYears().
Parameters
- 
                int$value optional
- The number of years to remove. 
Returns
staticsubYearWithOverflow() ¶ public
subYearWithOverflow(int $value = 1): staticRemove a year with overflow from the instance
Has the same behavior as addYearsWithOverflow().
Parameters
- 
                int$value optional
- The number of years to remove. 
Returns
staticsubYears() ¶ public
subYears(int $value): staticRemove years from the instance.
Has the same behavior as addYears().
Parameters
- 
                int$value
- The number of years to remove. 
Returns
staticsubYearsWithOverflow() ¶ public
subYearsWithOverflow(int $value): staticRemove years with overflow from the instance
Has the same behavior as addYearsWithOverflow().
Parameters
- 
                int$value
- The number of years to remove. 
Returns
statictimeAgoInWords() ¶ public
timeAgoInWords(array $options = []): stringReturns either a relative or a formatted absolute date depending on the difference between the current time and this object.
Options:
- from=> another Time object representing the "now" time
- format=> a fall back format if the relative time is longer than the duration specified by end
- accuracy=> Specifies how accurate the date should be described (array)- year => The format if years > 0 (default "day")
- month => The format if months > 0 (default "day")
- week => The format if weeks > 0 (default "day")
- day => The format if weeks > 0 (default "hour")
- hour => The format if hours > 0 (default "minute")
- minute => The format if minutes > 0 (default "minute")
- second => The format if seconds > 0 (default "second")
 
- end=> The end of relative time telling
- relativeString=> The- printfcompatible string when outputting relative time
- absoluteString=> The- printfcompatible string when outputting absolute time
- timezone=> The user timezone the timestamp should be formatted in.
Relative dates look something like this:
- 3 weeks, 4 days ago
- 15 seconds ago
Default date formatting is d/M/YY e.g: on 18/2/09. Formatting is done internally using
i18nFormat, see the method for the valid formatting strings
The returned string includes 'ago' or 'on' and assumes you'll properly add a word like 'Posted ' before the function output.
NOTE: If the difference is one week or more, the lowest level of accuracy is day
Parameters
- 
                array$options optional
- Array of options. 
Returns
stringRelative time string.
timestamp() ¶ public
timestamp(int $value): staticSet the instance's timestamp
Parameters
- 
                int$value
- The timestamp value to set. 
Returns
statictimezone() ¶ public
timezone(DateTimeZone|string $value): staticAlias for setTimezone()
Parameters
- 
                DateTimeZone|string$value
- The DateTimeZone object or timezone name to use. 
Returns
statictoDateTimeString() ¶ public
toDateTimeString(): stringFormat the instance as date and time
Returns
stringtoDayDateTimeString() ¶ public
toDayDateTimeString(): stringFormat the instance with day, date and time
Returns
stringtoFormattedDateString() ¶ public
toFormattedDateString(): stringFormat the instance as a readable date
Returns
stringtoImmutable() ¶ public
toImmutable(): Cake\Chronos\ChronosCreate a new immutable instance from current mutable instance.
Returns
Cake\Chronos\ChronostoQuarter() ¶ public
toQuarter(bool $range = false): string[]|intReturns the quarter
Parameters
- 
                bool$range optional
- Range. 
Returns
string[]|int1, 2, 3, or 4 quarter of year, or array if $range true
toUnixString() ¶ public
toUnixString(): stringReturns a UNIX timestamp.
Returns
stringUNIX timestamp
today() ¶ public static
today(DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance for today
Parameters
- 
                DateTimeZone|string|null$tz optional
- The timezone to use. 
Returns
statictomorrow() ¶ public static
tomorrow(DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance for tomorrow
Parameters
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
statictz() ¶ public
tz(DateTimeZone|string $value): staticAlias for setTimezone()
Parameters
- 
                DateTimeZone|string$value
- The DateTimeZone object or timezone name to use. 
Returns
staticwasWithinLast() ¶ public
wasWithinLast(string|int $timeInterval): boolReturns true this instance happened within the specified interval
Parameters
- 
                string|int$timeInterval
- the numeric value with space then time type. Example of valid types: 6 hours, 2 days, 1 minute. 
Returns
boolyear() ¶ public
year(int $value): staticSet the instance's year
Parameters
- 
                int$value
- The year value. 
Returns
staticyesterday() ¶ public static
yesterday(DateTimeZone|string|null $tz = null): staticCreate a ChronosInterface instance for yesterday
Parameters
- 
                DateTimeZone|string|null$tz optional
- The DateTimeZone object or timezone name the new instance should use. 
Returns
staticProperty Detail
$_jsonEncodeFormat ¶ protected static
The format to use 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 (http://www.icu-project.org/apiref/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.
Type
string|array|int$_toStringFormat ¶ protected static
The format to use when formatting a time using Cake\I18n\Time::i18nFormat()
and __toString. This format is also used by parseDateTime().
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 (http://www.icu-project.org/apiref/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.
Type
string|array|int$defaultLocale ¶ protected static
The default locale to be used for displaying formatted date strings.
Use static::setDefaultLocale() and static::getDefaultLocale() instead.
Type
string$diffFormatter ¶ protected static
Instance of the diff formatting object.
Type
Cake\Chronos\DifferenceFormatterInterface|null$dst ¶ public @property-read
daylight savings time indicator, true if DST, false otherwise
Type
bool$local ¶ public @property-read
checks if the timezone is local, true if local, false otherwise
Type
bool$niceFormat ¶ public static
The format to use when formatting a time using Cake\I18n\Time::nice()
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 (http://www.icu-project.org/apiref/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.
Type
string|array|int$toStringFormat ¶ protected static
Format to use for __toString method when type juggling occurs.
Type
string$wordAccuracy ¶ public static
The format to use when formatting a time using Time::timeAgoInWords()
and the difference is less than Time::$wordEnd
Type
string[]$wordFormat ¶ public static
The format to use when formatting a time using Cake\I18n\Time::timeAgoInWords()
and the difference is more than Cake\I18n\Time::$wordEnd
Type
string|array|int