PHP timezone_name_from_abbr() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Date/Time

Definition

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');
CallWhat 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

ParameterDescription
abbrRequired. The time zone abbreviation, such as EST or CET. Matching is not case sensitive. Pass an empty string to search by offset only.
utcOffsetOptional. 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.
isDSTOptional. 1 for daylight saving time, 0 for standard time, or -1 to ignore it. The default is -1.

Return Value

Return ValueDescription
stringThe matching time zone identifier, such as Europe/Berlin.
falseReturned 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.

PHP
<?php
echo timezone_name_from_abbr('CET'), PHP_EOL;
echo timezone_name_from_abbr('EST'), PHP_EOL;
echo timezone_name_from_abbr('PST'), PHP_EOL;

How It Works

  1. CET means Central European Time and PHP maps it to Europe/Berlin.
  2. EST means Eastern Standard Time and maps to America/New_York.
  3. PST means Pacific Standard Time and maps to America/Los_Angeles.
  4. Each result is a full identifier that you can pass to timezone_open().

Example 2 — Searching by UTC Offset

When you leave the abbreviation empty, PHP uses the offset in seconds and the daylight saving flag to find a zone.

PHP
<?php
echo timezone_name_from_abbr('', -18000, 0), PHP_EOL;
echo timezone_name_from_abbr('', -28800, 0), PHP_EOL;

How It Works

  1. An empty abbreviation tells PHP to ignore the name and look at the numbers.
  2. -18000 seconds is five hours behind UTC, which matches New York in standard time.
  3. -28800 seconds is eight hours behind UTC, which matches Los Angeles in standard time.
  4. 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;
}

How It Works

  1. XYZ is not a real abbreviation, so the function returns false.
  2. The strict comparison === false catches that case and prints a message.
  3. CET is valid, so the function returns Europe/Berlin.
  4. 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().

Next: timezone_name_get()

timezone_name_get() returns the name of the time zone stored in a DateTimeZone object.

timezone_name_get() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful