|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-11-26 06:49 UTC] kenji dot uui at gmail dot com
Description:
------------
DateTimeZone::getTransitions() changed between PHP 8.0.13 and 8.1.0.
Test script:
---------------
<?php
$tz = new DateTimeZone('America/Chicago');
$start = 1293861600;
$end = 1357020000;
$transitions = $tz->getTransitions($start, $end);
var_dump($transitions);
Expected result:
----------------
array(5) {
[0]=>
array(5) {
["ts"]=>
int(1293861600)
["time"]=>
string(24) "2011-01-01T06:00:00+0000"
["offset"]=>
int(-21600)
["isdst"]=>
bool(false)
["abbr"]=>
string(3) "CST"
}
[1]=>
array(5) {
["ts"]=>
int(1300003200)
["time"]=>
string(24) "2011-03-13T08:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
[2]=>
array(5) {
["ts"]=>
int(1320562800)
["time"]=>
string(24) "2011-11-06T07:00:00+0000"
["offset"]=>
int(-21600)
["isdst"]=>
bool(false)
["abbr"]=>
string(3) "CST"
}
[3]=>
array(5) {
["ts"]=>
int(1331452800)
["time"]=>
string(24) "2012-03-11T08:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
[4]=>
array(5) {
["ts"]=>
int(1352012400)
["time"]=>
string(24) "2012-11-04T07:00:00+0000"
["offset"]=>
int(-21600)
["isdst"]=>
bool(false)
["abbr"]=>
string(3) "CST"
}
}
Actual result:
--------------
array(1) {
[0]=>
array(5) {
["ts"]=>
int(1293861600)
["time"]=>
string(24) "2011-01-01T06:00:00+0000"
["offset"]=>
int(-18000)
["isdst"]=>
bool(true)
["abbr"]=>
string(3) "CDT"
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 02:00:01 2025 UTC |
Currently @derick's patch from php> = 8.1.0beta3 without parameters returns from one (if it has never used transition) or more transition arrays. Otherwise with parameter it returns the last transition period of the year UTC which is different from its local timezone if different from UTC. 2010-12-31 00:00:00 America/Chicago and 2011-01-01 06:00:00 UTC. Do you want to calculate the time of the year between two dates? that is to say: array(5) { ["ts"]=> int(1300003200) ["time"]=> string(24) "2011-03-13T08:00:00+0000" ["offset"]=> int(-18000) ["isdst"]=> bool(true) ["abbr"]=> string(3) "CDT" } relative to fix bug 80963> Do you want to calculate the time of the year between two dates? No. Our use case is just wanting to know it is daylight saving time or not. We use DateTime::format('I').