English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and examples of PHP timezone_identifiers_list() function

PHP Date & Time Function Manual

The timezone_identifiers_list() function returns an indexed array containing all timezone identifiers.

Definition and usage

The timezone_identifiers_list() function is an alias for DateTimeZone::listIdentifiers(). This function returns all identifiers in PHP in array form.

Syntax

timezone_identifiers_list([$what, $country])

Parameter

Serial numberParameters and descriptions
1

what (optional)

This is an integer value that specifies the DateTimeZone class constant representing the continent.
1 = AFRICA
2 = AMERICA
4 = ANTARCTICA
8 = ARCTIC
16 = ASIA
32 = ATLANTIC
64 = AUSTRALIA
128 = EUROPE
256 = INDIAN
512 = PACIFIC
1024 = UTC
2047 = ALL
4095 = ALL_WITH_BC
4096 = PER_COUNTRY

2

what (optional)

 Consisting of two letters, ISO 3166-1 Compatible country codes.
 Note: This option will only be used when what is set to DateTimeZone::PER_COUNTRY.

Return value

This function returns an array containing a list of timezone identifiers. If it fails, it returns a boolean valuefalse.

PHP version

This function was originally introduced in PHP version5.2introduced in version 5.2.0 and can be used in all higher versions.

Online example

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] => ....
    .........

Online example

$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