Bug #74914 [Opn->Dup]: DateInterval subtraction across daylight savings change is incorrect
| From: | requinix@php.net | Date: | Thu, 13 Jul 2017 05:30:12 +0000 |
| Subject: | Bug #74914 [Opn->Dup]: DateInterval subtraction across daylight savings change is incorrect | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210037@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74914&edit=1
ID: 74914
Updated by: requinix@php.net
Reported by: ricjea at sbcglobal dot net
Summary: DateInterval subtraction across daylight savings
change is incorrect
-Status: Open
+Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: Windows Server 2012
PHP Version: 5.6.31
Block user comment: N
Private report: N
New Comment:
Duplicate of at least two other bugs I remember seeing.
Previous Comments:
------------------------------------------------------------------------
[2017-07-12 23:55:35] ricjea at sbcglobal dot net
Description:
------------
Found in PHP 5.6.31, still exists in version 7 as per testing with https://3v4l.org/35D4t
If you subtract a DateInterval that ends during the spring daylight savings time transition, the
wrong DateTime and DateTime->getTimestamp() are returned. See example. If the DateInterval spans
the full transition, then it is ok.
Test script:
---------------
$a = new \DateTime('2016-03-13 3:00:00', new
DateTimeZone('America/Los_Angeles'));
echo "Original Timestamp: ".$a->getTimeStamp()."\n";
$b = clone $a;
$b->sub(new \DateInterval('PT1S'));
echo "Subtract 1 second Timestamp: ".$b->getTimeStamp()."\n";
print_r([$a,$b]);
Expected result:
----------------
Original Timestamp: 1457863200
Subtract 1 second Timestamp: 1457863199
Array
(
[0] => DateTime Object
(
[date] => 2016-03-13 03:00:00.000000
[timezone_type] => 3
[timezone] => America/Los_Angeles
)
[1] => DateTime Object
(
[date] => 2016-03-13 01:59:59.000000
[timezone_type] => 3
[timezone] => America/Los_Angeles
)
)
Actual result:
--------------
Original Timestamp: 1457863200
Subtract 1 second Timestamp: 1457866799
Array
(
[0] => DateTime Object
(
[date] => 2016-03-13 03:00:00.000000
[timezone_type] => 3
[timezone] => America/Los_Angeles
)
[1] => DateTime Object
(
[date] => 2016-03-13 03:59:59.000000
[timezone_type] => 3
[timezone] => America/Los_Angeles
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74914&edit=1