PHP Tutorial - PHP date_timezone_get() Function






Definition

The date_timezone_get() function returns the time zone of the given DateTime object.

Syntax

PHP date_timezone_get() Function has the following syntax.

date_timezone_get(object);

Parameter

PHP date_timezone_get() Function has the following parameters.

  • object - Required. DateTime object returned by date_create().

Return

PHP date_timezone_get() Function returns a DateTimeZone object on success. FALSE on failure.





Example

Return the timezone of the given DateTime object:


<?php
    $date=date_create(null,timezone_open("Europe/Paris"));
    $tz=date_timezone_get($date);
    echo timezone_name_get($tz);
?>

The code above generates the following result.