PHP date_timezone_get() function

PHP date_timestamp_set() function
PHP date_timezone_set() function

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)
ParameterDescription
objectRequired. Specifies a DateTime object returned by date_create().
PHP date_timezone_get() method

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);
?>

PHP date_timestamp_set() function
PHP date_timezone_set() function
en English
X
Scroll to Top