Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

date_offset_get()

Example

Retrieve the timezone offset for Oslo (Norway, Europe) in seconds from UTC, including both winter and summer times.

<?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.”;
?>

Definition and Usage

The date_offset_get() function returns the timezone offset of a DateTime object.

Syntax

date_offset_get(object)

Parameter Values

Parameter

Description

object

Required. Specifies a DateTime object created by date_create().

Technical Details

Return Value:

Returns the timezone offset in seconds from UTC on success; FALSE on failure.

PHP Version:

5.2+