note 73995 added to function.timezone-offset-get
| From: | richard at phase dot org | Date: | Tue, 20 Mar 2007 11:05:54 +0000 |
| Subject: | note 73995 added to function.timezone-offset-get | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124619@lists.php.net to get a copy of this message | ||
The following extended example may make the usage clearer;
<?php
// Create two timezone objects, one for Taipei (Taiwan) and one for
// Tokyo (Japan)
$dateTimeZoneTaipei = new DateTimeZone("Asia/Taipei");
$dateTimeZoneJapan = new DateTimeZone("Asia/Tokyo");
// Create two DateTime objects that will contain the same Unix timestamp, but
// have different timezones attached to them.
$dateTimeTaipei = new DateTime("now", $dateTimeZoneTaipei);
$dateTimeJapan = new DateTime("now", $dateTimeZoneJapan);
// NOTE: $dateTimeJapan is not used further in this example
// Calculate the GMT offset for the date/time contained in the $dateTimeTaipei
// object, but using the timezone rules as defined for Tokyo
// ($dateTimeZoneJapan).
$timeOffset = $dateTimeZoneJapan->getOffset($dateTimeTaipei);
// Should show int(32400) (for dates after Sat Sep 8 01:00:00 1951 JST).
print("Number of seconds Japan is ahead of GMT at the specific time: ");
var_dump($timeOffset);
print("<br />Number of seconds Taipei is ahead of GMT at the specific time: ");
var_dump($dateTimeZoneTaipei->getOffset($dateTimeTaipei));
print("<br />Number of seconds Japan is ahead of Taipei at the specific time: ");
var_dump($dateTimeZoneJapan->getOffset($dateTimeTaipei)
-$dateTimeZoneTaipei->getOffset($dateTimeTaipei));
print("<hr />");
?>
Number of seconds Japan is ahead of GMT at the specific time: int(32400)
Number of seconds Taipei is ahead of GMT at the specific time: int(28800)
Number of seconds Japan is ahead of Taipei at the specific time: int(3600)
----
Server IP: 194.145.210.4
Probable Submitter: 87.74.47.50
----
Manual Page -- http://www.php.net/manual/en/function.timezone-offset-get.php
Edit -- https://master.php.net/note/edit/73995
Del: integrated -- https://master.php.net/note/delete/73995/integrated
Del: useless -- https://master.php.net/note/delete/73995/useless
Del: bad code -- https://master.php.net/note/delete/73995/bad+code
Del: spam -- https://master.php.net/note/delete/73995/spam
Del: non-english -- https://master.php.net/note/delete/73995/non-english
Del: in docs -- https://master.php.net/note/delete/73995/in+docs
Del: other reasons-- https://master.php.net/note/delete/73995
Reject -- https://master.php.net/note/reject/73995
Search -- https://master.php.net/manage/user-notes.php