W3docs

timezone_identifiers_list()

PHP's function date timezone identifiers are used to specify a timezone for a given date or time. These identifiers can be used with the

Introduction

The timezone_identifiers_list() function returns an array of every timezone identifier that PHP knows about. Timezone identifiers are strings in the Area/Location format (for example America/New_York, Europe/London, Asia/Tokyo) and come from the IANA timezone database bundled with PHP.

This page covers the function's signature, how to read its return value, how to filter the list by continent or country, and the most common real-world uses: building a timezone dropdown and validating user-supplied timezone names.

Syntax

timezone_identifiers_list(
    int $timezoneGroup = DateTimeZone::ALL,
    ?string $countryCode = null
): array

Both parameters are optional and were added in PHP 5.3, with the country filter behavior refined in later versions:

  • $timezoneGroup — a DateTimeZone constant that limits the result to a region, such as DateTimeZone::EUROPE, DateTimeZone::AMERICA, or DateTimeZone::ASIA. The default DateTimeZone::ALL returns every standard identifier.
  • $countryCode — a two-letter ISO 3166-1 country code (for example 'US', 'GB', 'IN'). It only takes effect when $timezoneGroup is set to DateTimeZone::PER_COUNTRY.

The function returns a numerically indexed array of strings. The identifiers are returned in alphabetical order.

timezone_identifiers_list() is the procedural alias of DateTimeZone::listIdentifiers() — both produce the same result.

Listing all identifiers

<?php

$identifiers = timezone_identifiers_list();

echo count($identifiers) . " timezones\n";
echo $identifiers[0] . "\n";
echo $identifiers[1] . "\n";

Output (the exact count depends on your PHP/IANA version):

419 timezones
Africa/Abidjan
Africa/Accra

You can iterate over the array to print every available timezone:

<?php

foreach (timezone_identifiers_list() as $tz) {
    echo $tz . "\n";
}

Filtering by region or country

Pass a DateTimeZone group constant to narrow the list to one continent:

<?php

$european = timezone_identifiers_list(DateTimeZone::EUROPE);

echo $european[0] . "\n"; // Europe/Amsterdam

To get the timezones for a single country, use DateTimeZone::PER_COUNTRY together with a country code:

<?php

$usZones = timezone_identifiers_list(DateTimeZone::PER_COUNTRY, 'US');

echo $usZones[0] . "\n"; // America/Adak
echo in_array('America/New_York', $usZones, true) ? "found\n" : "missing\n"; // found

This is handy when you want a country-aware picker — for example, showing only US timezones after a user selects "United States".

Validating user input

Because the function returns an authoritative list, it is the safest way to check whether a timezone string is valid before passing it to DateTimeZone or date_default_timezone_set():

<?php

function isValidTimezone(string $tz): bool
{
    return in_array($tz, timezone_identifiers_list(), true);
}

var_dump(isValidTimezone('Europe/London'));     // bool(true)
var_dump(isValidTimezone('Mars/Olympus_Mons')); // bool(false)

Applying an identifier

Once you have a valid identifier, set it as the script-wide default with date_default_timezone_set():

<?php

date_default_timezone_set('America/New_York');

Or create a DateTimeZone object to attach a timezone to a specific date without changing the global default:

<?php

$timezone = new DateTimeZone('Asia/Tokyo');
$date = new DateTime('now', $timezone);

echo $date->format('Y-m-d H:i:s P');

PHP also accepts a fixed UTC offset instead of a named zone. This skips daylight-saving rules entirely:

<?php

$timezone = new DateTimeZone('-08:00');

Notes and gotchas

  • The list is built from the IANA database shipped with your PHP build, so the exact identifiers and count can change between PHP versions. Use timezone_version_get() to check which database version is active.
  • Some legacy identifiers are deprecated and may be dropped in future releases. Prefer canonical Area/Location names over abbreviations.
  • For timezone abbreviations (like CET or PST) rather than full identifiers, see timezone_abbreviations_list().
  • For a broader overview of working with time zones in PHP, read PHP Timezones.

Practice

Practice

Practice
Which of the following is a valid timezone identifier in PHP?
Which of the following is a valid timezone identifier in PHP?
Was this page helpful?