yongtiger / timezone
Installs: 90
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:php
Requires
- php: >=5.5
This package is not auto-updated.
Last update: 2024-10-26 20:58:45 UTC
README
FEATURES
USAGE
- Usecase #1: using sort flags
$tzs = TimeZone::timezone_list(TimeZone::SORT_BY_OFFSET);
- This will generate an array looking like:
[Pacific/Midway] => (UTC-11:00) Pacific/Midway
[Pacific/Pago_Pago] => (UTC-11:00) Pacific/Pago_Pago
[Pacific/Niue] => (UTC-11:00) Pacific/Niue
[Pacific/Honolulu] => (UTC-10:00) Pacific/Honolulu
[Pacific/Fakaofo] => (UTC-10:00) Pacific/Fakaofo
...
- Usecase #2: customized your own
static::$timezones
TimeZone::$timezones = DateTimeZone::listIdentifiers(); $tzs = TimeZone::timezone_list();
- Usecase #3: using output format template
$tzs = TimeZone::timezone_list(TimeZone::SORT_BY_OFFSET, '(GMT{offset_prefix}{offset_formatted}) {timezone}'); $tzs = TimeZone::timezone_list(TimeZone::SORT_BY_OFFSET, '(GMT{offset_prefix}{offset_formatted})'); $tzs = TimeZone::timezone_list(TimeZone::SORT_BY_OFFSET, '(UTC{offset_prefix}{offset}) - {timezone}');
- Usecase #4: using timezone output format template
echo TimeZone::timezone_format($timeZone)
NOTES
DOCUMENTS
SEE ALSO
- http://stackoverflow.com/questions/1727077/generating-a-drop-down-list-of-timezones-with-php
- http://stackoverflow.com/questions/24059235/php-sort-an-array-by-value-and-for-equal-values-sort-by-key
- http://stackoverflow.com/questions/31183575/access-array-key-using-uasort-in-php
- http://php.net/manual/en/function.uksort.php
- http://stackoverflow.com/questions/4755704/php-timezone-list
- https://gist.github.com/Xeoncross/1204255
- https://randomdrake.com/2008/08/06/time-zone-abbreviation-difficulties-with-php/
TODO
Development roadmap
LICENSE
Timezone is released under the MIT license, see LICENSE file for details.