Copyright © tutorialspoint.com
|
int timezone_offset_get ( $object, $datetime ); int DateTimeZone::getOffset ( $datetime ); |
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.
| Parameter | Description |
|---|---|
| object | Required. A date and time zone object |
| datetime | Required. DateTime that contains the date/time to compute the offset from. |
Returns time zone offset in seconds on success or FALSE on failure.
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) |
Copyright © tutorialspoint.com