PHP timezone_name_get() Function

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

Definition

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

The name depends on how the zone was created. A zone made from an identifier gives that identifier, such as Asia/Tokyo. A zone made from an offset gives the offset text, and a zone made from an abbreviation gives the abbreviation. It is the procedural version of DateTimeZone::getName().

Syntax

Call timezone_name_get() with the values you need. Start with this line.

PHP
$name = timezone_name_get($tz);
CallWhat it does
timezone_name_get($tz)Returns the name of the DateTimeZone object $tz.
timezone_name_get($date->getTimezone())Reads the time zone name of an existing DateTime object.
$tz->getName()The object-oriented version that returns the same string.

The function always returns a string and never false. The text you get back is the same text that was used to create the DateTimeZone object.

Library declarations
PHP
timezone_name_get(DateTimeZone $object): string

Parameters

ParameterDescription
objectRequired. A DateTimeZone object, usually created with timezone_open() or new DateTimeZone().

Return Value

Return ValueDescription
stringThe time zone name, such as Europe/Paris, +05:30, EST or UTC.

PHP Examples

Example 1 — Getting the Name of a Zone

Create a zone for Tokyo and read its name.

PHP
<?php
$tz = timezone_open('Asia/Tokyo');

echo timezone_name_get($tz), PHP_EOL;

How It Works

  1. timezone_open() creates a DateTimeZone object for Asia/Tokyo.
  2. timezone_name_get() reads the name back from the object.
  3. The result is the same identifier that was used to create the zone.

Example 2 — Names from Different Inputs

The name you get back depends on what you passed when you created the zone.

PHP
<?php
$inputs = ['Europe/Paris', '+05:30', 'EST', 'UTC'];

foreach ($inputs as $input) {
    $tz = timezone_open($input);
    echo $input, ' => ', timezone_name_get($tz), PHP_EOL;
}

How It Works

  1. The loop creates one DateTimeZone object for each input.
  2. An identifier, an offset, an abbreviation and UTC are all valid inputs.
  3. timezone_name_get() returns the same text that was passed in.
  4. This is why the name is not always an identifier that you can look up in a list.

Example 3 — Reading the Zone from a DateTime

You can also read the name from a DateTime object by first getting its time zone.

PHP
<?php
$tz = new DateTimeZone('America/Chicago');
$date = new DateTime('2026-06-15 10:00:00', $tz);

echo timezone_name_get($date->getTimezone()), PHP_EOL;
var_dump(timezone_name_get($tz) === $tz->getName());

How It Works

  1. The DateTime object is created in the America/Chicago zone.
  2. getTimezone() returns a DateTimeZone object for that date.
  3. timezone_name_get() reads the name from it.
  4. The procedural function and the getName() method give identical results.

Frequently Asked Questions

It returns the name of a DateTimeZone object as a string, such as Europe/London, +02:00 or UTC.
Yes. It is the procedural alias of the getName() method.
Call $date->getTimezone()->getName(), or use timezone_name_get($date->getTimezone()).
The zone was created from an offset, so the name is just the offset text. Create the zone with the identifier Asia/Kolkata if you want that name.
Use date_default_timezone_get(). It returns the identifier set by date_default_timezone_set() or by the date.timezone setting in php.ini.

Next: timezone_offset_get()

timezone_offset_get() returns the offset from UTC, in seconds, for a time zone at a specif.

timezone_offset_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