PHP date_offset_get() function

PHP date_parse() function
PHP date_parse_from_format() function

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)
ParameterDetails
objectThe DateTime Object to get the timezone offset from – Required
PHP date_offset_get() method

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";
?>
PHP date_parse() function
PHP date_parse_from_format() function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top