|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-01-10 08:15 UTC] z dot dacto at gmail dot com
Description:
------------
When optional argument `$timestamp_begin` is provided to `DateTimeZone::getTransitions` the first transition returned assumes a `ts` value of `$timestamp_begin` and a `time` value formatted from `$timestamp_begin`.
The first transition should instead be the one active during `$timestamp_begin`.
Test script:
---------------
<!DOCTYPE html>
<html>
<body>
<pre>
<?php
$tz = new DateTimeZone('America/Los_Angeles');
# 1509872300 = 11-05-2017T8:58:20+0000
# 1515570270 = 01-10-2018T7:44:30+0000
$transition = $tz->getTransitions(1509872300, 1515570270);
print_r($transition);
?>
</pre>
</body>
</html>
Expected result:
----------------
Array
(
[0] => Array
(
[ts] => 1489312800
[time] => 2017-03-12T10:00:00+0000
[offset] => -25200
[isdst] => 1
[abbr] => PDT
)
[1] => Array
(
[ts] => 1509872400
[time] => 2017-11-05T09:00:00+0000
[offset] => -28800
[isdst] =>
[abbr] => PST
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[ts] => 1509872300
[time] => 2017-11-05T08:58:20+0000
[offset] => -25200
[isdst] => 1
[abbr] => PDT
)
[1] => Array
(
[ts] => 1509872400
[time] => 2017-11-05T09:00:00+0000
[offset] => -28800
[isdst] =>
[abbr] => PST
)
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 06:00:01 2025 UTC |
While it is by design, is this the correct behavior since the first element isn't actually a valid timezone transition? Aside from the what I mentioned in the original description, an alternative interpretation for DateTimeZone::getTransitions(start,end) would be such that only timezone transitions that happen between start and end would be included in the resulting array. Applied to the Test SCript, this should then result in: Array ( [0] => Array ( [ts] => 1509872400 [time] => 2017-11-05T09:00:00+0000 [offset] => -28800 [isdst] => [abbr] => PST ) )