PHP | timezone_offset_get() Function Last Updated : 16 Aug, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: 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. Return Value: It returns the timezone offset in seconds on success or False on failure. Exceptions: The timezone_offset_get() function is an alias of DateTimeZone::getOffset() function. Below programs illustrate the timezone_offset_get() function in PHP: Program 1: php <?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: -18000 Program 2: php <?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: int(7200) Related Articles: PHP | timezone_location_get() Function PHP | timezone_open() Function PHP | timezone_name_from_abbr() Function Reference: http://php.net/manual/en/function.timezone-offset-get.php Comment More infoAdvertise with us Next Article PHP | timezone_offset_get() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time PHP-function +1 More Practice Tags : Misc Similar Reads PHP | timezone_name_get() Function The timezone_name_get() function is an inbuilt function in PHP which is used to return the name of the timezone. The date time object is sent as a parameter to the timezone_name_get() function and it returns the name of the timezone on success or False on failure. Syntax: string timezone_name_get( $ 2 min read PHP | timezone_location_get() Function The timezone_location_get() function is an inbuilt function in PHP which is used to return the location information for the given timezone. The date time object is sent as a parameter to the timezone_location_get() function and it returns location information related to the timezone on success or Fa 2 min read PHP | timezone_open() Function The timezone_open() function is an inbuilt function in PHP which is used to create a new DateTimeZone object. The timezone_open() function accepts the timezone as a parameter and returns the DateTimeZone object on success or False on failure. Syntax: timezone_open( $timezone ) Parameters: This funct 2 min read PHP | date_timezone_get() Function The date_timezone_get() function is an inbuilt function in PHP which is used to return time zone relative to given DateTime. This function returns a DateTimeZone object on success or False on failure. Syntax: Procedural style: date_timezone_get( $object ) Object oriented style: DateTime::getTimezone 1 min read PHP | date_offset_get() Function The date_offset_get() function is an inbuilt function in PHP which is used to returns the timezone offset. This function returns the timezone offset in seconds from UTC (Universal Time Coordinated) on success or FALSE on failure. Syntax: Procedural Style: int date_offset_get( $object ) Object Orient 1 min read Like