Latest web development tutorials

PHP date_offset_get () function

PHP Date / Time PHP Date / Time Reference Manual

Examples

Back in Oslo (Norway in Europe) winter and summer relative to UTC time zone offset in seconds:

<?php
$winter=date_create("2013-12-31",timezone_open("Europe/Oslo"));
$summer=date_create("2013-06-30",timezone_open("Europe/Oslo"));

echo date_offset_get($winter) . " seconds.<br>";
echo date_offset_get($summer) . " seconds.";
?>

Running instance »

Definition and Usage

date_offset_get () function returns the time zone offset.

grammar

date_offset_get( object);

参数 描述
object 必需。规定一个由 date_create() 返回的 DateTime 对象。

technical details

return value: If successful with respect to UTC in seconds time zone, if it fails it returns FALSE.
PHP version: 5.2+


PHP Date / Time PHP Date / Time Reference Manual