Textpattern | PHP Cross Reference | Content Management Systems |
Description: Handles timezones.
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Timezone:: (8 methods):
getTimeZones()
getOffsetIdentifiers()
isDst()
getDstPeriod()
getTimeZoneAbbreviation()
getIdentifier()
setTimeZone()
getTimeZone()
getTimeZones() line: 73 |
Gets an array of safe timezones supported on this server. The following: <code> print_r(Txp::get('\Textpattern\Date\Timezone')->getTimeZones()); </code> Returns: <code> Array ( [America/New_York] => Array ( [continent] => America [city] => New_York [subcity] => [offset] => -18000 [dst] => 1 ) [Europe/London] => Array ( [continent] => Europe [city] => London [subcity] => [offset] => 0 [dst] => 1 ) ) </code> Offset is the timezone offset from UTC excluding daylight saving time, DST is whether it's currently DST in the timezone. Identifiers are sorted alphabetically. return: array|bool An array of timezones, or FALSE on failure |
getOffsetIdentifiers($offset) line: 142 |
Gets timezone identifiers for the given timezone offset. More than one timezone might fit any given offset, thus the returned value is ambiguous and merely useful for presentation purposes. <code> print_r(Txp::get('\Textpattern\Date\Timezone')->getOffsetIdentifiers(3600)); </code> Returns: <code> Array ( [0] => Africa/Malabo [1] => Europe/Amsterdam [2] => Europe/Berlin [3] => Europe/Zurich ) </code> return: array|bool An array of timezone identifiers, or FALSE param: int $offset Offset in seconds |
isDst($timestamp = null, $timezone = null) line: 177 |
Whether DST is in effect. The given timestamp can either be a date format supported by DateTime, UNIX timestamp or NULL to check current status. If timezone is NULL, checks the server default timezone. <code> echo Txp::get('\Textpattern\Date\Timezone')->isDst('2013/06/20', 'Europe/London'); </code> Returns TRUE, while this returns FALSE as the timezone does not use daylight saving time: <code> echo Txp::get('\Textpattern\Date\Timezone')->isDst('2013/06/20', 'Africa/Accra'); </code> If it's winter this returns FALSE: <code> echo Txp::get('\Textpattern\Date\Timezone')->isDst(null, 'Europe/London'); </code> return: bool TRUE if timezone is using DST param: string|int|null $timestamp Time to check param: string|null $timezone Timezone identifier |
getDstPeriod($timezone = null, $from = null) line: 236 |
Gets the next daylight saving transition period for the given timezone. Returns FALSE if the timezone does not use DST, or will in the future drop DST. <code> print_r(Txp::get('\Textpattern\Date\Timezone')->getDstPeriod('Europe/Helsinki')); </code> Returns: <code> Array ( [0] => Array ( [ts] => 1396141200 [time] => 2014-03-30T01:00:00+0000 [offset] => 10800 [isdst] => 1 [abbr] => EEST ) [1] => Array ( [ts] => 1414285200 [time] => 2014-10-26T01:00:00+0000 [offset] => 7200 [isdst] => [abbr] => EET ) ) </code> return: array|bool An array of next two transitions, or FALSE param: string|null $timezone The timezone identifier param: int $from Next transitions starting from when |
getTimeZoneAbbreviation($timezone = null, $dst = false) line: 310 |
Gets timezone abbreviation. If the $timezone is NULL, uses the server default. Returns FALSE if there is no abbreviation to give. <code> echo Txp::get('\Textpattern\Date\Timezone')->getTimeZoneAbbreviation('Europe/London'); </code> Returns 'GMT', while the following returns 'FALSE': <code> echo Txp::get('\Textpattern\Date\Timezone')->getTimeZoneAbbreviation('Africa/Accra', true); </code> As according to the timezone database, the timezone does not currently use DST. return: string|bool The abbreviation, or FALSE on failure param: string $timezone Timezone identifier param: bool $dst TRUE to get the abbreviation during DST |
getIdentifier($timezone = null) line: 370 |
Gets a timezone identifier. Extracts information about the given timezone. If the $timezone is NULL, uses the server's default timezone. <code> print_r(Txp::get('\Textpattern\Date\Timezone')->getIdentifier('Europe/London')); </code> Returns: <code> Array ( [continent] => Europe [city] => London [subcity] => [offset] => 0 [dst] => 1 ) </code> return: array|bool An array, or FALSE on failure param: string|null $timezone Timezone identifier |
setTimeZone($identifiers) line: 436 |
Sets the server default timezone. If an array of identifiers is given, the first one supported is used. <code> echo Txp::get('\Textpattern\Date\Timezone')->setTimeZone('UTC'); </code> Throws an exception if the identifier isn't valid. return: Timezone param: array|string $identifiers The timezone identifier |
getTimeZone() line: 463 |
Gets the server default timezone. <code> echo Txp::get('\Textpattern\Date\Timezone')->setTimeZone('Europe/London')->getTimeZone(); </code> The above returns 'Europe/London'. return: string|bool Timezone identifier |
title