| Fully Qualified Name: | CodeIgniter\I18n\Time |
| Extends: | DateTime |
Class Time
A localized date/time package inspired by Nesbot/Carbon and CakePHP/Chronos.
Requires the intl PHP extension.
| Name | Description | Defined By |
|---|---|---|
| __construct() | Time constructor. | Time |
| __get() | Allow for property-type access to any getX method. | Time |
| __isset() | Allow for property-type checking to any getX method. | Time |
| __toString() | Outputs a short format version of the datetime. | Time |
| addDays() | Returns a new Time instance with $days added to the time. | Time |
| addHours() | Returns a new Time instance with $hours added to the time. | Time |
| addMinutes() | Returns a new Time instance with $minutes added to the time. | Time |
| addMonths() | Returns a new Time instance with $months added to the time. | Time |
| addSeconds() | Returns a new Time instance with $seconds added to the time. | Time |
| addYears() | Returns a new Time instance with $years added to the time. | Time |
| create() | Returns a new instance with the date time values individually set. | Time |
| createFromDate() | Returns a new instance based on the year, month and day. If any of those three are left empty, will default to the current value. | Time |
| createFromFormat() | Provides a replacement for DateTime's own createFromFormat function, that provides more flexible timeZone handling | Time |
| createFromTime() | Returns a new instance with the date set to today, and the time set to the values passed in. | Time |
| createFromTimestamp() | Returns a new instance with the datetime set based on the provided UNIX timestamp. | Time |
| difference() | Time | |
| equals() | Determines if the datetime passed in is equal to the current instance. | Time |
| getAge() | Returns the age in years from the "current" date and 'now' | Time |
| getCalendar() | Returns the IntlCalendar object used for this object, taking into account the locale, date, etc. | Time |
| getDay() | Return the localized day of the month. | Time |
| getDayOfWeek() | Return the index of the day of the week | Time |
| getDayOfYear() | Return the index of the day of the year | Time |
| getDst() | Are we in daylight savings time currently? | Time |
| getHour() | Return the localized hour (in 24-hour format). | Time |
| getLocal() | Returns boolean whether the passed timezone is the same as the local timezone. | Time |
| getMinute() | Return the localized minutes in the hour. | Time |
| getMonth() | Returns the localized Month | Time |
| getQuarter() | Returns the number of the current quarter for the year. | Time |
| getSecond() | Return the localized seconds | Time |
| getTimezoneName() | Returns the name of the current timezone. | Time |
| getUTCObject() | Returns a Time instance with the timezone converted to UTC. | Time |
| getUtc() | Returns boolean whether object is in UTC. | Time |
| getWeekOfMonth() | Return the index of the week in the month | Time |
| getWeekOfYear() | Return the index of the week in the year | Time |
| getYear() | Returns the localized Year | Time |
| hasTestNow() | Returns whether we have a testNow instance saved. | Time |
| humanize() | Returns a text string that is easily readable that describes how long ago, or how long from now, a date is, like: | Time |
| instance() | Takes an instance of DateTime and returns an instance of Time with it's same values. | Time |
| isAfter() | Determines if the current instance's time is after $testTime, after converting in UTC. | Time |
| isBefore() | Determines if the current instance's time is before $testTime, after converting to UTC. | Time |
| now() | Returns a new Time instance with the timezone set. | Time |
| parse() | Returns a new Time instance while parsing a datetime string. | Time |
| sameAs() | Ensures that the times are identical, taking timezone into account. | Time |
| setDay() | Sets the day of the month. | Time |
| setHour() | Sets the hour of the day (24 hour cycle) | Time |
| setMinute() | Sets the minute of the hour | Time |
| setMonth() | Sets the month of the year. | Time |
| setSecond() | Sets the second of the minute. | Time |
| setTestNow() | Creates an instance of Time that will be returned during testing when calling 'Time::now' instead of the current time. | Time |
| setTimestamp() | Returns a new instance with the date set to the new timestamp. | Time |
| setTimezone() | Returns a new instance with the revised timezone. | Time |
| setYear() | Sets the current year for this instance. | Time |
| subDays() | Returns a new Time instance with $days subtracted from the time. | Time |
| subHours() | Returns a new Time instance with $hours subtracted from the time. | Time |
| subMinutes() | Returns a new Time instance with $minutes subtracted from the time. | Time |
| subMonths() | Returns a new Time instance with $months subtracted from the time. | Time |
| subSeconds() | Returns a new Time instance with $seconds subtracted from the time. | Time |
| subYears() | Returns a new Time instance with $hours subtracted from the time. | Time |
| toDateString() | Returns a localized version of the date in Y-m-d format. | Time |
| toDateTime() | Converts the current instance to a mutable DateTime object. | Time |
| toDateTimeString() | Returns the localized value of the date in the format 'Y-m-d H:i:s' | Time |
| toFormattedDateString() | Returns a localized version of the date in nicer date format: | Time |
| toLocalizedString() | Returns the localized value of this instance in $format. | Time |
| toTimeString() | Returns a localized version of the time in nicer date format: | Time |
| today() | Return a new time with the time set to midnight. | Time |
| tomorrow() | Returns an instance set to midnight tomorrow morning. | Time |
| yesterday() | Returns an instance set to midnight yesterday morning. | Time |
Time constructor.
| Parameter Name | Type | Description |
|---|---|---|
| $time | string|null | |
| $timezone | null | |
| $locale | string|null |
Returns:
Allow for property-type access to any getX method.
..
Note that we cannot use this for any of our setX methods, as they return new Time objects, but the __set ignores return values. See http://php.net/manual/en/language.oop5.overloading.php
| Parameter Name | Type | Description |
|---|---|---|
| $name | ||
| $name |
Returns: mixed
Allow for property-type checking to any getX method.
..
| Parameter Name | Type | Description |
|---|---|---|
| $name | ||
| $name |
Returns: bool
Outputs a short format version of the datetime.
Returns: string
Returns a new Time instance with $days added to the time.
| Parameter Name | Type | Description |
|---|---|---|
| $days | int |
Returns: static
Returns a new Time instance with $hours added to the time.
| Parameter Name | Type | Description |
|---|---|---|
| $hours | int |
Returns: static
Returns a new Time instance with $minutes added to the time.
| Parameter Name | Type | Description |
|---|---|---|
| $minutes | int |
Returns: static
Returns a new Time instance with $months added to the time.
| Parameter Name | Type | Description |
|---|---|---|
| $months | int |
Returns: static
Returns a new Time instance with $seconds added to the time.
| Parameter Name | Type | Description |
|---|---|---|
| $seconds | int |
Returns: static
Returns a new Time instance with $years added to the time.
| Parameter Name | Type | Description |
|---|---|---|
| $years | int |
Returns: static
Returns a new instance with the date time values individually set.
| Parameter Name | Type | Description |
|---|---|---|
| $year | int|null | |
| $month | int|null | |
| $day | int|null | |
| $hour | int|null | |
| $minutes | int|null | |
| $seconds | int|null | |
| $timezone | null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Returns a new instance based on the year, month and day. If any of those three are left empty, will default to the current value.
| Parameter Name | Type | Description |
|---|---|---|
| $year | int|null | |
| $month | int|null | |
| $day | int|null | |
| $timezone | null | |
| $locale | string |
Returns: \CodeIgniter\I18n\Time
Provides a replacement for DateTime's own createFromFormat function, that provides more flexible timeZone handling
| Parameter Name | Type | Description |
|---|---|---|
| $format | string | |
| $datetime | string | |
| $timeZone | \DateTimeZone|string |
Returns: \CodeIgniter\I18n\Time
Returns a new instance with the date set to today, and the time set to the values passed in.
| Parameter Name | Type | Description |
|---|---|---|
| $hour | int|null | |
| $minutes | int|null | |
| $seconds | int|null | |
| $timezone | null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Returns a new instance with the datetime set based on the provided UNIX timestamp.
| Parameter Name | Type | Description |
|---|---|---|
| $timestamp | int | |
| $timeZone | \DateTimeZone | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
| Parameter Name | Type | Description |
|---|---|---|
| $testTime | ||
| $timezone | string|null | |
| $testTime |
Returns: \CodeIgniter\I18n\TimeDifference
Determines if the datetime passed in is equal to the current instance.
Equal in this case means that they represent the same moment in time, and are not required to be in the same timezone, as both times are converted to UTC and compared that way.
| Parameter Name | Type | Description |
|---|---|---|
| $testTime | \Time|\DateTime|string | |
| $timezone | string|null |
Returns: bool
Returns the age in years from the "current" date and 'now'
Returns:
Returns the IntlCalendar object used for this object, taking into account the locale, date, etc.
Primarily used internally to provide the difference and comparison functions, but available for public consumption if they need it.
Returns: \IntlCalendar
Return the localized day of the month.
Returns: string
Return the index of the day of the week
Returns: string
Return the index of the day of the year
Returns: string
Are we in daylight savings time currently?
Returns: bool
Return the localized hour (in 24-hour format).
Returns: string
Returns boolean whether the passed timezone is the same as the local timezone.
Returns: bool
Return the localized minutes in the hour.
Returns: string
Returns the localized Month
Returns: string
Returns the number of the current quarter for the year.
Returns: string
Return the localized seconds
Returns: string
Returns the name of the current timezone.
Returns: string
Returns a Time instance with the timezone converted to UTC.
| Parameter Name | Type | Description |
|---|---|---|
| $time | ||
| $timezone | string|null | |
| $time |
Returns: \DateTime|static
Returns boolean whether object is in UTC.
Returns: bool
Return the index of the week in the month
Returns: string
Return the index of the week in the year
Returns: string
Returns the localized Year
Returns: string
Returns whether we have a testNow instance saved.
Returns: bool
Returns a text string that is easily readable that describes how long ago, or how long from now, a date is, like:
Returns: mixed
Takes an instance of DateTime and returns an instance of Time with it's same values.
| Parameter Name | Type | Description |
|---|---|---|
| $dateTime | \DateTime | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Determines if the current instance's time is after $testTime, after converting in UTC.
| Parameter Name | Type | Description |
|---|---|---|
| $testTime | ||
| $timezone | string|null | |
| $testTime |
Returns: bool
Determines if the current instance's time is before $testTime, after converting to UTC.
| Parameter Name | Type | Description |
|---|---|---|
| $testTime | ||
| $timezone | string|null | |
| $testTime |
Returns: bool
Returns a new Time instance with the timezone set.
| Parameter Name | Type | Description |
|---|---|---|
| $timezone | string|\DateTimeZone|null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Returns a new Time instance while parsing a datetime string.
Example: $time = Time::parse('first day of December 2008');
| Parameter Name | Type | Description |
|---|---|---|
| $datetime | string | |
| $timezone | string|null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Ensures that the times are identical, taking timezone into account.
| Parameter Name | Type | Description |
|---|---|---|
| $testTime | \Time|\DateTime|string | |
| $timezone | string|null |
Returns: bool
Sets the day of the month.
| Parameter Name | Type | Description |
|---|---|---|
| $value | ||
| $value |
Returns: \CodeIgniter\I18n\Time
Sets the hour of the day (24 hour cycle)
| Parameter Name | Type | Description |
|---|---|---|
| $value | ||
| $value |
Returns: \CodeIgniter\I18n\Time
Sets the minute of the hour
| Parameter Name | Type | Description |
|---|---|---|
| $value | ||
| $value |
Returns: \CodeIgniter\I18n\Time
Sets the month of the year.
| Parameter Name | Type | Description |
|---|---|---|
| $value | ||
| $value |
Returns: \CodeIgniter\I18n\Time
Sets the second of the minute.
| Parameter Name | Type | Description |
|---|---|---|
| $value | ||
| $value |
Returns: \CodeIgniter\I18n\Time
Creates an instance of Time that will be returned during testing when calling 'Time::now' instead of the current time.
| Parameter Name | Type | Description |
|---|---|---|
| $datetime | \CodeIgniter\I18n\Time|string | |
| $timezone | null | |
| $locale | string|null |
Returns:
Returns a new instance with the date set to the new timestamp.
| Parameter Name | Type | Description |
|---|---|---|
| $timestamp | int |
Returns: \CodeIgniter\I18n\Time
Returns a new instance with the revised timezone.
| Parameter Name | Type | Description |
|---|---|---|
| $timezone | \DateTimeZone |
Returns: \CodeIgniter\I18n\Time
Sets the current year for this instance.
| Parameter Name | Type | Description |
|---|---|---|
| $value | ||
| $value |
Returns: \CodeIgniter\I18n\Time
Returns a new Time instance with $days subtracted from the time.
| Parameter Name | Type | Description |
|---|---|---|
| $days | int |
Returns: static
Returns a new Time instance with $hours subtracted from the time.
| Parameter Name | Type | Description |
|---|---|---|
| $hours | int |
Returns: static
Returns a new Time instance with $minutes subtracted from the time.
| Parameter Name | Type | Description |
|---|---|---|
| $minutes | int |
Returns: static
Returns a new Time instance with $months subtracted from the time.
| Parameter Name | Type | Description |
|---|---|---|
| $months | int |
Returns: static
Returns a new Time instance with $seconds subtracted from the time.
| Parameter Name | Type | Description |
|---|---|---|
| $seconds | int |
Returns: static
Returns a new Time instance with $hours subtracted from the time.
| Parameter Name | Type | Description |
|---|---|---|
| $years | int |
Returns: static
Returns a localized version of the date in Y-m-d format.
Returns: string
Converts the current instance to a mutable DateTime object.
Returns: \DateTime
Returns the localized value of the date in the format 'Y-m-d H:i:s'
Returns:
Returns a localized version of the date in nicer date format:
i.e. Apr 1, 2017
Returns: string
Returns the localized value of this instance in $format.
| Parameter Name | Type | Description |
|---|---|---|
| $format | string|null |
Returns: string|bool
Returns a localized version of the time in nicer date format:
i.e. 13:20:33
Returns: string
Return a new time with the time set to midnight.
| Parameter Name | Type | Description |
|---|---|---|
| $timezone | null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Returns an instance set to midnight tomorrow morning.
| Parameter Name | Type | Description |
|---|---|---|
| $timezone | null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time
Returns an instance set to midnight yesterday morning.
| Parameter Name | Type | Description |
|---|---|---|
| $timezone | null | |
| $locale | string|null |
Returns: \CodeIgniter\I18n\Time