note 96574 modified in datetimezone.gettransitions by danbrown
| From: | danbrown@php.net | Date: | Fri, 05 Mar 2010 23:37:42 +0000 |
| Subject: | note 96574 modified in datetimezone.gettransitions by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166725@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:
$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