Class Date

Methods summary

public
# toDB( string|integer|DateTime $value = 'now', string $fromTimezone = 'system' )

Convert any date/time representation to a string that can be used in DB queries.

public string|integer
# getOverridableNow( boolean $asTimestamp = false )

Return the date/time representation for now, that can be overridden by a custom request when viewing pages in a moment specified by administrators (custom request date/time).

public string
# date( string $mask, boolean|integer $timestamp = false, $toTimezone = 'system' )

Subsitute for the native date() function that adds localized date support. Use ONLY if really needed: you may want to use some of the formatDate/Time methods. If you're not working with timestamps you may want to use the formatCustom method.

public array
# getTimezones( )

Returns a keyed array of timezone identifiers (keys are the standard PHP timezone names, values are the localized timezone names)

public string
# getTimezoneDisplayName( string|DateTimeZone|DateTime $timezone )

Returns the display name of a timezone

public string
# timeSince( integer $posttime, boolean $precise = false )

Describe the difference in time between now and a date/time in the past. If the date/time is in the future or if it's more than one year old, you'll get the date representation of $posttime

public string
# describeInterval( integer $diff, boolean $precise = false )

Returns the localized representation of a time interval specified as seconds.

public string
# getTimezoneID( string $timezone )

Returns the normalized timezone identifier

public DateTimeZone|null
# getTimezone( string $timezone )

Returns a \DateTimeZone instance for a specified timezone identifier

public DateTime|null
# toDateTime( string|DateTime|integer $value = 'now', string $toTimezone = 'system', string $fromTimezone = 'system' )

Convert a date to a \DateTime instance.

public integer|null
# getDeltaDays( mixed $from, mixed $to, string $timezone = 'user' )

Returns the difference in days between to dates.

public string
# formatDate( mixed $value = 'now', boolean $longDate = false, string $toTimezone = 'user' )

Render the date part of a date/time as a localized string

public string
# formatTime( mixed $value = 'now', boolean $withSeconds = false, string $toTimezone = 'user' )

Render the time part of a date/time as a localized string

public string
# formatDateTime( mixed $value = 'now', boolean $longDate = false, boolean $withSeconds = false, string $toTimezone = 'user' )

Render both the date and time parts of a date/time as a localized string

public string
# formatPrettyDate( mixed $value, boolean $longDate = false, string $toTimezone = 'user' )

Render the date part of a date/time as a localized string. If the day is yesterday we'll print 'Yesterday' (the same for today, tomorrow)

public string
# formatPrettyDateTime( mixed $value, boolean $longDate = false, boolean $withSeconds = false, string $timezone = 'user' )

Render both the date and time parts of a date/time as a localized string. If the day is yesterday we'll print 'Yesterday' (the same for today, tomorrow)

public string
# formatCustom( string $format, mixed $value = 'now', string $toTimezone = 'user', string $fromTimezone = 'system' )

Render a date/time as a localized string, by specifying a custom format

public string
# getJQueryUIDatePickerFormat( string $relatedPHPFormat = '' )

Returns the format string for the jQueryUI DatePicker widget

public integer
# getTimeFormat( )

Returns the time format (12 or 24)

public
# getLocalDateTime( $systemDateTime = 'now', $mask = null )
public
# getSystemDateTime( $userDateTime = 'now', $mask = null )
public
# dateTimeFormatLocal( $datetime, $mask )

Constants summary

string DB_FORMAT

The PHP date/time format string to be used when dealing with the database.

# 'Y-m-d H:i:s'