PHP | timezone_offset_get() Function
Last Updated :
11 Jul, 2025
Improve
The timezone_offset_get() function is an inbuilt function in PHP which is used to return the timezone offset from GMT. The date time object and the date-time are sent as a parameter to the timezone_offset_get() function and return the timezone offset in seconds on success or False on failure.
Syntax:
php
php
int timezone_offset_get( $object, $datetime )Parameters: This function accepts two parameter as mentioned above and described below:
- $object: It is a mandatory parameter which specifies the DateTimeZone object.
- $datetime: It is also a mandatory parameter which specifies the date/time from which the offset has to be computed.
<?php
// Open the timezone of America/Chicago
$timezone = timezone_open("America/Chicago");
// Displaying the offset of America/Chicago and Europe/Amsterdam
$datetime_eur = date_create("now", timezone_open("Europe/Amsterdam"));
echo timezone_offset_get($timezone, $datetime_eur);
?>
Output:
Program 2:
-18000
<?php
// Open the timezone of America/Chicago and Europe/Amsterdam
$timezone_chicago = new DateTimeZone("America/Chicago");
$timezone_amsterdam = new DateTimeZone("Europe/Amsterdam");
$chicago = new DateTime("now", $timezone_chicago);
$amsterdam = new DateTime("now", $timezone_amsterdam);
// Calculating the offset between the timezones
$Offset = $timezone_amsterdam -> getOffset($chicago);
// Dumping the offset variable
var_dump($Offset);
?>
Output:
Related Articles:
int(7200)
- PHP | timezone_location_get() Function
- PHP | timezone_open() Function
- PHP | timezone_name_from_abbr() Function