In PHP, timezone_name_from_abbr() returns a time zone name that matches an abbreviation, such as CET or EST, or that matches a UTC offset.
It is useful when you only have a short code or an offset and want a full identifier like Europe/Berlin. The function picks one likely match, because many zones share the same abbreviation. If nothing matches, it returns false.
Syntax
Call timezone_name_from_abbr() with the values you need. Start with this line.
PHP
$name = timezone_name_from_abbr('CET');
Call
What it does
timezone_name_from_abbr('CET')
Looks up a zone name from the abbreviation CET.
timezone_name_from_abbr('', -18000, 0)
Leaves the abbreviation empty and searches by an offset of -18000 seconds and no daylight saving.
timezone_name_from_abbr('XYZ')
Returns false because the abbreviation is not known.
The result is only a best guess, because one abbreviation can belong to many places. Use it as a fallback when you cannot get a real identifier from the user.
Library declarations
PHP
timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string|false
Parameters
Parameter
Description
abbr
Required. The time zone abbreviation, such as EST or CET. Matching is not case sensitive. Pass an empty string to search by offset only.
utcOffset
Optional. The offset from UTC in seconds, for example 3600 for UTC+1. The default -1 means the offset is ignored when an abbreviation is given.
isDST
Optional. 1 for daylight saving time, 0 for standard time, or -1 to ignore it. The default is -1.
Return Value
Return Value
Description
string
The matching time zone identifier, such as Europe/Berlin.
false
Returned when no time zone matches.
PHP Examples
Example 1 — Finding a Zone from an Abbreviation
Pass a well-known abbreviation and print the identifier that PHP chooses.
An empty abbreviation tells PHP to ignore the name and look at the numbers.
-18000 seconds is five hours behind UTC, which matches New York in standard time.
-28800 seconds is eight hours behind UTC, which matches Los Angeles in standard time.
The third argument 0 says that daylight saving time is not in effect.
Example 3 — Handling an Unknown Abbreviation
An unknown abbreviation returns false. Check for it before you build a DateTimeZone from the result.
PHP
<?php
$name = timezone_name_from_abbr('XYZ');
if ($name === false) {
echo "Unknown abbreviation", PHP_EOL;
}
$name = timezone_name_from_abbr('CET');
if ($name !== false) {
$tz = new DateTimeZone($name);
echo $tz->getName(), PHP_EOL;
}
Output
Unknown abbreviation
Europe/Berlin
How It Works
XYZ is not a real abbreviation, so the function returns false.
The strict comparison === false catches that case and prints a message.
CET is valid, so the function returns Europe/Berlin.
The valid name is safe to use with new DateTimeZone().
Frequently Asked Questions
It converts a time zone abbreviation, or an offset in seconds, into a full time zone identifier such as Europe/Berlin. It returns false if it finds no match.
Many zones share the abbreviation CET, so PHP picks one of them. The choice is a convention and you should not rely on it to match a specific city.
Pass an empty string as the first argument and give the offset in seconds as the second, for example timezone_name_from_abbr('', 3600, 0). The third argument tells PHP whether daylight saving time is on.
No. CET, cet and Cet all give the same result.
Check the result with === false and fall back to a default zone such as UTC, or ask the user to choose a zone from timezone_identifiers_list().