Home >>PHP Date Time Functions >PHP timezone_offset_get() Function

PHP timezone_offset_get() Function

PHP timezone_offset_get() Function

PHPtimezone_offset_get() function is used to get the timezone offset from the GMT. It accepts two parameters the date time object and the date-time. It returns the timezone offset in seconds as output on success and False on failure.

Syntax:

timezone_offset_get(object, datetime);

Parameter Values

Parameter Description
object This is a required parameter. This parameter defines a DateTimeZone object returned by timezone_open().
datetime This is a required parameter. This parameter defines a date/time to compute the offset from.

Here is an example of timezone_offset_get() function in PHP:

<html>
<body>
<?php
$asia=timezone_open("Asia/kolkata");
$oslo=date_create("now",timezone_open("Europe/Oslo"));
echo timezone_offset_get($asia,$oslo);
?>
</body>
</html>
Output:
19800

Example 2:

<html>
<body>
<?php
$paris=timezone_open("Europe/Paris");
$chicago=date_create("now",timezone_open("America/Chicago"));
echo timezone_offset_get($paris,$chicago);
?>
</body>
</html>
Output:
3600

No Sidebar ads