Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2013 TutorialsPoint.COM
|
PHP Function timezone_offset_get()
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
| Parameter | Description |
| object | Required. A date and time zone object |
| datetime | Required. 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:
Advertisements
|
|
|