Signature
timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string|falsePurpose
timezone_name_from_abbr() turns a short time zone label such as EST or UTC into a full time zone identifier such as America/New_York. It is a guessing helper. Abbreviations are ambiguous, so the function searches PHP's built-in abbreviation table and returns the first plausible identifier. Use it when all you have is legacy text such as an abbreviation or a bare offset and you need some identifier to hand to DateTimeZone.
The function has existed since PHP 5.1.3 and is available in PHP 8.4.
Signature
Parameters and defaults
$abbris the abbreviation to look up, for example"EST"or"UTC". It can be an empty string when you want to search by offset only.$utcOffsetis the offset from GMT in seconds. The default-1means that the first time zone found for$abbris returned. If you pass another value, PHP first looks for an exact offset match. Only if none is found does it fall back to the first zone for that abbreviation with any offset.$isDSTis the daylight saving indicator. The default-1means DST is ignored. Passing1says the offset includes daylight saving time, and0says it does not. If the abbreviation does not exist, PHP searches by$utcOffsetand$isDSTalone.
Return value and failure
The function returns the time zone name as a string on success and false on failure. Failure means nothing matched, for example an unknown abbreviation with no usable offset. The function does not throw for unknown input, so you must check the result with false.
Example 1: Looking up common abbreviations
The UTC abbreviation maps to UTC, and EST maps to a New York identifier.
$result = [
'utc' => timezone_name_from_abbr('UTC'),
'est' => timezone_name_from_abbr('EST'),
];
echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";{"utc":"UTC","est":"America/New_York"}
Example 2: Searching by offset only
When the abbreviation is empty, PHP searches by offset and DST flag. Here -18000 seconds is five hours behind UTC, with no daylight saving in effect.
$name = timezone_name_from_abbr('', -18000, 0);
echo json_encode($name, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";"America/New_York"
Example 3: Handling failure
Unknown input with the default offset and DST arguments produces false. Always handle it before using the value.
$results = [
timezone_name_from_abbr('nope'),
timezone_name_from_abbr(''),
];
echo json_encode($results), "\n";[false,false]
Edge cases
- Offsets are seconds, not hours. One hour is
3600, not1. Passing-1is not an offset of one hour behind; it is the "ignore offset" default. - Empty abbreviation and default offset. With nothing to search on, the result is
false, as shown in example 3. - A matching abbreviation with a mismatched offset. PHP still returns the first zone it knows for that abbreviation, so the offset you passed may not actually be honored.
- Several zones share one abbreviation. Many zones use
CST,ISTorBSTfor different regions. The function can return only one of them, and the manual describes the result as the first found. The manual's own example showsCETgiving a result such asEurope/Berlin, introduced as output "similar to" what you get, which signals that the particular city is a guess. - Offset-only searches pick a representative zone. A call such as example 2 gives a typical zone for that offset, not necessarily the zone of your user.
Common mistakes
- Treating the result as the user's real zone. An abbreviation does not identify a place. If you can collect an identifier like
Europe/Parisdirectly, do that instead. - Forgetting the
falsecheck. Passingfalseonward intonew DateTimeZone()leads to an error or a misleading conversion. Test with=== falsefirst. - Using hours for
$utcOffset. The parameter is in seconds. - Assuming the DST flag is a filter in every case. It is only used meaningfully together with an offset, or when the abbreviation is not known.
- Relying on the exact city for business rules. Billing, scheduling and legal deadlines depend on real zone rules, which can differ between cities that share an offset today.
Related functions
timezone_abbreviations_list()is an alias ofDateTimeZone::listAbbreviations(). It exposes the table that this function searches, so you can see every candidate for an abbreviation.timezone_identifiers_list()lists valid identifiers you can offer in a selection menu.DateTimeZoneis the class that turns an identifier into a usable zone object.
Recap
timezone_name_from_abbr() guesses an identifier from an abbreviation, an offset in seconds and an optional DST flag. It returns a string or false. It is handy for legacy data but inherently ambiguous, so check for false, pass offsets in seconds, and prefer a real identifier whenever you can get one.
Tested examples
$result = [
'utc' => timezone_name_from_abbr('UTC'),
'est' => timezone_name_from_abbr('EST'),
];
echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";
{"utc":"UTC","est":"America/New_York"}
$name = timezone_name_from_abbr('', -18000, 0);
echo json_encode($name, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), "\n";
"America/New_York"
$results = [
timezone_name_from_abbr('nope'),
timezone_name_from_abbr(''),
];
echo json_encode($results), "\n";
[false,false]