waDateTime

Date and time processing

Contents...

Methods

public static function date ($format, $time = null, $timezone = null, $locale = null)

Returns date as string according to the specified format.

Parameters

Example

waDateTime::date('F j, Y', '06-11-2013')

Result

November 6, 2013

public static function format ($format, $time = null, $timezone = null, $locale = null)

Returns time as string according to the specified format.

Parameters

Example

waDateTime::format('humandatetime')

Result

Today 17:11

PHP functions

function wa_date ($format, $time = null, $timezone = null, $locale = null)

Wrapper for method format.

Example

wa_date('humandatetime')

Result

Today 17:11

Smarty modifiers

{$timestamp |wa_date [:format='date' :$timezone=null :$locale=null]}

Formats a timestamp using method format. By default, format string date is used.

Example

{'1384761717'|wa_date}

Result

11/18/2013

{$timestamp |wa_datetime [:format='datetime' :$timezone=null :$locale=null]}

Formats a timestamp using method format. By default, format string datetime is used..

Example

{'1384761717'|wa_datetime}

Result

11/18/2013 12:01

public static function getDefaultTimeZone()

Returns the default time zone using PHP function date_default_timezone_get.

Example

waDateTime::getDefaultTimeZone()

Result

America/New_York

public static function getFormat ($format, $locale = null)

Returns format strings for PHP function date corresponding to formats used by Webasyst framework.

Parameters

Example

waDateTime::getFormat ('humandate', 'en_US')

Result

F j, Y

public static function getFormatJS ($format, $locale = null)

Returns format strings for date/time formatting by means of JavaScript code corresponding to formats used by Webasyst framework.

Parameters

Example

waDateTime::getFormatJS ('humandate', 'en_US')

Result

MM d, yy

public static function getTimeZones()

Returns the list of available time zones with localized descriptions.

Example

waDateTime::getTimeZones()

Result

Array
(
    [Pacific/Apia] => −11 Apia, Midway, Niue, Pago Pago
    [Pacific/Fakaofo] => −10 Fakaofo, Honolulu, Johnston, Rarotonga, Tahiti
    [America/Adak] => −09 Adak
    [Pacific/Gambier] => −09 Gambier, Marquesas
    [America/Anchorage] => −08 Anchorage, Juneau, Nome, Sitka, Yakutat
    [Pacific/Pitcairn] => −08 Pitcairn
    [America/Dawson] => −07 Dawson, Dawson Creek, Hermosillo, Los Angeles, Metlakatla
    ...
    [Pacific/Efate] => +11 Efate, Guadalcanal, Kosrae, Norfolk, Noumea
    [Pacific/Pohnpei] => +11 Pohnpei
    [Antarctica/McMurdo] => +12 McMurdo, South Pole
    [Asia/Anadyr] => +12 Anadyr, Kamchatka, Magadan
    [Pacific/Auckland] => +12 Auckland, Chatham, Fiji, Funafuti, Kwajalein
    [Pacific/Majuro] => +12 Majuro, Nauru, Tarawa, Wake, Wallis
    [Pacific/Enderbury] => +13 Enderbury, Tongatapu
    [Pacific/Kiritimati] => +14 Kiritimati
)

public static function parse ($format, $string, $timezone = null, $locale = null)

Returns time value, formatted using one of the formats supported by Webasyst framework, as a string acceptable by standard PHP functions.

Parameters

Example

waDateTime::parse ('humandate', 'November 8, 2013', null, 'en_US')

Result

2013-11-08

PHP functions

function wa_parse_date ($format, $string, $timezone = null, $locale = null)

Wrapper for calling method parse.

Example

wa_parse_date ('humandate', 'November 8, 2013', null, 'en_US')

Result

2013-11-08