In this article, you will learn how to get the timezone offset from the give date. The date_offset_get() function returns the timezone offset from the specified date.
What is the syntax of the date_offset_get() function in PHP?
date_offset_get(object)
Parameter | Details |
---|---|
object | The DateTime Object to get the timezone offset from – Required |
Examples of the date_offset_get() function
Example 1. In the following example, we create a date using the date_create method and find their timezone offset using the function.
<?php
$x=date_create("2014-11-13",timezone_open("Europe/Oslo"));
$y=date_create("2013-06-30",timezone_open("Europe/Oslo"));
echo date_offset_get($x) " seconds";
echo date_offset_get($y) " seconds";
?>