PHP timezone_offset_get() Function

PHP timezone_open() Function
PHP timezone_name_get() Function

In this article, you will learn how to get the timezone offset. The timezone_offset_get()
the method in PHP returns the offset of the timezone from the GMT.

What is the syntax of the timezone_offset_get() function in PHP?

timezone_offset_get(object, datetime)
ParameterDescription
objectThe DateTime object is returned by the timezone_open method. – Required
datetimeDate/time to allow the function to get offset from it – Required
PHP timezone_offset_get() method

Example of the timezone_offset_get() function

Example 1. In this example, we create a new timezone object using the timezone_open() method and a date/time object. We pass both of these objects to the timezone_offset_get() function to calculate the offset.

<?php
$timezone=timezone_open("Asia/Taipei");
$oslo=date_create("now",timezone_open("Europe/Oslo"));
echo timezone_offset_get($timezone,$oslo);
?>
PHP timezone_open() Function
PHP timezone_name_get() Function
en English
X
Scroll to Top