Home >>PHP Date Time Functions >PHP date_timezone_get() Function
PHP date_timezone_get() function is used to return time zone relative to given DateTime value. It returns a DateTimeZone object as output on success or False on failure. It accepts only a single parameter $object which is the DateTime object returned by the date_create() function.
Syntax:
date_timezone_get(object);
Parameter | Description |
---|---|
object | This is a required parameter. This parameter defines the DateTime object returned by date_create(). |
Here is an example of date_timezone_get() function in PHP:
<html> <body> <?php $date=date_create(null,timezone_open("Asia/kolkata")); echo timezone_name_get(date_timezone_get($date)); ?> </body> </html>
Example 2:
<html> <body> <?php $date=date_create(); echo timezone_name_get(date_timezone_get($date)); ?> </body> </html>