In PHP, timezone_identifiers_list() returns an array of time zone identifiers, such as Europe/London or Asia/Kolkata.
By default it returns every standard identifier. You can limit the list to one region, like Europe or America, or to the zones used by a single country. It is the procedural version of DateTimeZone::listIdentifiers() and is handy for building a time zone drop-down.
Syntax
Call timezone_identifiers_list() with the values you need. Start with this line.
Returns the identifiers used by one country, here India.
The list is sorted alphabetically. When you use DateTimeZone::PER_COUNTRY you must also pass a two-letter ISO 3166-1 country code, otherwise PHP throws a ValueError.
Optional. One of the DateTimeZone group constants, such as ALL, AFRICA, AMERICA, ASIA, EUROPE, PACIFIC, UTC or PER_COUNTRY. The default is DateTimeZone::ALL.
countryCode
Optional. A two-letter country code such as US or IN. It is required when the group is DateTimeZone::PER_COUNTRY and ignored otherwise.
Return Value
Return Value
Description
array
A list of time zone identifier strings, sorted alphabetically.
PHP Examples
Example 1 — Counting and Checking Identifiers
The full list is long, so this example prints only the first three identifiers and checks a few names with in_array().
India zones: 1
Asia/Kolkata
bool(true)
bool(true)
bool(true)
How It Works
PER_COUNTRY needs the second argument, here the code IN for India.
India uses one time zone, so the list has a single item: Asia/Kolkata.
The United States spans many zones, so its list has more than one item.
New York and Los Angeles are both listed for US.
Frequently Asked Questions
It returns an array of time zone identifier strings like America/New_York or Asia/Tokyo, sorted alphabetically.
Call timezone_identifiers_list(DateTimeZone::PER_COUNTRY, 'US'), replacing US with a two-letter ISO country code. The second argument is required with PER_COUNTRY.
Pass a group constant as the first argument, for example DateTimeZone::EUROPE, DateTimeZone::ASIA or DateTimeZone::AMERICA.
Yes. The function is the procedural alias of DateTimeZone::listIdentifiers(), and both take the same arguments and return the same array.
Use in_array($name, timezone_identifiers_list(), true). This is a simple and reliable check before you pass the name to date_default_timezone_set() or timezone_open().