PHP date_timezone_get() Function

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

Definition

In PHP, date_timezone_get() returns the timezone of a date object as a DateTimeZone object.

It is the procedural name for DateTime::getTimezone() and DateTimeImmutable::getTimezone(). You can then read its name with timezone_name_get() or reuse it for another date.

Syntax

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

PHP
$tz = date_timezone_get($date);
CallWhat it does
date_timezone_get($date)Returns a DateTimeZone object for the date.
timezone_name_get(date_timezone_get($date))Returns the timezone name, such as Asia/Kolkata.
date_timezone_get($date)->getName()The object-style way to read the same name.

The name depends on how the date was created. A date made with a named timezone returns a name like Europe/Paris, while a date with a fixed offset returns text like +02:00. In new code you can call $date->getTimezone() on a DateTimeImmutable.

Library declarations
PHP
date_timezone_get(DateTimeInterface $object): DateTimeZone|false

Parameters

ParameterDescription
objectRequired. A DateTime or DateTimeImmutable object.

Return Value

Return ValueDescription
DateTimeZoneA new DateTimeZone object for the date's timezone.
falseReturned on failure.

PHP Examples

Example 1 — Read the Timezone Name

Create a date in India and ask which timezone it uses.

PHP
<?php
$date = date_create("2024-01-15 12:00:00", timezone_open("Asia/Kolkata"));

$tz = date_timezone_get($date);

echo timezone_name_get($tz), PHP_EOL;
echo $tz->getName(), PHP_EOL;
echo get_class($tz), PHP_EOL;

How It Works

  1. The date is created with the Asia/Kolkata timezone.
  2. date_timezone_get() returns a DateTimeZone object for that date.
  3. timezone_name_get() and the getName() method both return the same name.
  4. get_class() confirms the result is a DateTimeZone object.

Example 2 — Offsets and Abbreviations

The name you get back depends on how the date was written.

PHP
<?php
$offset = date_create("2024-01-15 12:00:00+02:00");
$abbr = date_create("2024-01-15 12:00:00 EST");
$utc = date_create("2024-01-15 12:00:00 UTC");

echo timezone_name_get(date_timezone_get($offset)), PHP_EOL;
echo timezone_name_get(date_timezone_get($abbr)), PHP_EOL;
echo timezone_name_get(date_timezone_get($utc)), PHP_EOL;

How It Works

  1. A date written with +02:00 has a fixed offset, so the name is +02:00.
  2. A date written with EST keeps the abbreviation as its name.
  3. A date written with UTC returns UTC.
  4. Only dates made with a named timezone, such as Europe/Paris, return a full region name.

Example 3 — Reuse a Timezone for Another Date

Take the timezone from one date and use it to create another.

PHP
<?php
$first = date_create("2024-01-15 09:00:00", timezone_open("Europe/Paris"));
$tz = date_timezone_get($first);

$second = date_create("2024-07-04 09:00:00", $tz);

echo timezone_name_get($tz), PHP_EOL;
echo date_format($second, "Y-m-d H:i T"), PHP_EOL;

How It Works

  1. Create the first date in the Europe/Paris timezone.
  2. date_timezone_get() copies that timezone into $tz.
  3. Pass $tz to date_create() to make a second date in the same timezone.
  4. In July Paris uses summer time, so the format character T shows CEST.

Frequently Asked Questions

It returns a DateTimeZone object for the timezone of a date. Use timezone_name_get() or getName() to read its name.
Call timezone_name_get(date_timezone_get($date)), or with objects use $date->getTimezone()->getName().
That happens when the date was created with a fixed offset instead of a timezone name. Such dates have no region, so the offset is the name.
Use date_timezone_set($date, $timezone), or call setTimezone() on a DateTimeImmutable. date_timezone_get() only reads it.
Yes. It is the procedural alias of getTimezone() and works with both DateTime and DateTimeImmutable.

Next: date_timezone_set()

date_timezone_set() changes the timezone of a DateTime object, so the same moment is shown.

date_timezone_set() 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