note 96574 modified in datetimezone.gettransitions by aharvey
| From: | aharvey@php.net | Date: | Mon, 10 Sep 2012 01:18:45 +0000 |
| Subject: | note 96574 modified in datetimezone.gettransitions by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190597@lists.php.net to get a copy of this message | ||
Getting a timezone's offset and other data at a specified point in time (now, for example)
using the new PHP5.3
parameters: <?php $theTime = time(); #
specific date/time we're checking, in epoch seconds. $tz
= new DateTimeZone('America/Los_Angeles'); $transition =
$tz->getTransitions($theTime,$theTime); # only one array
should be returned into $transition. Now get the data: $offset =
$transition[0]['offset']; $abbr =
$transition[0]['abbr']; ?> Before
PHP5.3, you'd have to loop through all of the Transitions up until the current point in
time, which would be a very inefficient process.
--was--
Getting a timezone's offset and other data at a specified point in time (now, for example)
using the new PHP5.3 parameters:
<?php
$theTime = time(); # specific date/time we're checking, in epoch seconds.
$tz = new DateTimeZone('America/Los_Angeles');
$transition = $tz-getTransitions($theTime,$theTime);
# only one array should be returned into $transition. Now get the data:
$offset = $transition[0]['offset'];
$abbr = $transition[0]['abbr'];
?>
Before PHP5.3, you'd have to loop through all of the Transitions up until the current point in
time, which would be a very inefficient process.
http://php.net/manual/en/datetimezone.gettransitions.php