In this article, you will learn how to get the timezone from the date. The date_timezone_get() function returns the time zone from the given DateTime object.
What is the syntax of the date_timezone_get() function in PHP?
date_timezone_get(object)
Parameter | Description |
---|---|
object | Required. Specifies a DateTime object returned by date_create(). |
Example of the date_timezone_get() function
Example 1. In this example, we create a DateTime object using the date_create() method and then get the timezone from it.
<?php
$d=date_create(null,timezone_open("Europe/Paris"));
$time_zone=date_timezone_get($d);
echo timezone_name_get($time_zone);
?>