PHP date_timezone_get() Function
In this chapter you will learn:
- Definition for PHP date_timezone_get() Function
- Syntax for PHP date_timezone_get() Function
- Parameter for PHP date_timezone_get() Function
- Return value for PHP date_timezone_get() Function
- Example - Return the timezone of the given DateTime object
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//from j a va 2s .co m
$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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date_timezone_set() Function
- Syntax for PHP date_timezone_set() Function
- Parameter for PHP date_timezone_set() Function
- Return for PHP date_timezone_set() Function
- Example - Set the timezone for the DateTime object
Home » PHP Tutorial » PHP Date Functions