Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function timezone_offset_get()


previous

Advertisements

Syntax

int timezone_offset_get ( $object, $datetime );

int DateTimeZone::getOffset ( $datetime );

Definition and Usage

These functions return the timezone offset from GMT.

The above two functions are equivalent and any of the functions can be used as shown below in the example.

Paramters

ParameterDescription
objectRequired. A date and time zone object
datetimeRequired. DateTime that contains the date/time to compute the offset from.

Return Value

Returns time zone offset in seconds on success or FALSE on failure.

Example

Following is the usage of this function:

<?php
$dateTimeZoneTaipei = new DateTimeZone("Asia/Taipei");
$dateTimeZoneJapan = new DateTimeZone("Asia/Tokyo");

$dateTimeTaipei = new DateTime("now", $dateTimeZoneTaipei);
$dateTimeJapan = new DateTime("now", $dateTimeZoneJapan);

$timeOffset = $dateTimeZoneJapan->getOffset($dateTimeTaipei);

var_dump($timeOffset);
?>

This will produce following result:

int(32400)

previous Printer Friendly

Advertisements


  

Advertisements