English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Date & Time Function Manual
The timezone_identifiers_list() function returns an indexed array containing all timezone identifiers.
The timezone_identifiers_list() function is an alias for DateTimeZone::listIdentifiers(). This function returns all identifiers in PHP in array form.
timezone_identifiers_list([$what, $country])
Serial number | Parameters and descriptions |
---|---|
1 | what (optional) This is an integer value that specifies the DateTimeZone class constant representing the continent. |
2 | what (optional) Consisting of two letters, ISO 3166-1 Compatible country codes. |
This function returns an array containing a list of timezone identifiers. If it fails, it returns a boolean valuefalse.
This function was originally introduced in PHP version5.2introduced in version 5.2.0 and can be used in all higher versions.
The following example demonstratestimezone_identifiers_list()Function to output all Asian time zones:
<h3>Output all Asian time zones</h3> <?php print_r(timezone_identifiers_list(16)); ?> <h3>Output all time zones</h3> <?php print_r(timezone_identifiers_list()); ?>Test and see‹/›
Output result
Array ( [0] => Asia/Aden [1] => Asia/Almaty [2] => Asia/Amman [3] => Asia/Anadyr [4] => Asia/Aqtau [5] => Asia/Aqtobe [6] => Asia/Ashgabat [7] => Asia/Atyrau [8] => Asia/Baghdad [9] => Asia/Bahrain [10] => Asia/Baku [11] => Asia/Bangkok [12] => Asia/Barnaul [13] => .... .........
$timezone_identifiers = DateTimeZone::listIdentifiers(); for ($i = 0; $i < 5; $i++) { echo "$timezone_identifiers[$i]\n"; } echo "-------------------------------------------------\n"; $timezone_identifiers = timezone_identifiers_list(); for ($i = 0; $i < 5; $i++) { echo "$timezone_identifiers[$i]\n"; }Test and see‹/›
Output result:
Africa/Abidjan Africa/Accra Africa/Addis Ababa Africa/Algiers Africa/Asmara ------------------------------------------------- Africa/Abidjan Africa/Accra Africa/Addis Ababa Africa/Algiers Africa/Asmara