Bug #73138 [Asn->Dup]: strtotime miscalculates when exiting DST with relative time

From: Date: Fri, 01 Oct 2021 16:09:59 +0000
Subject: Bug #73138 [Asn->Dup]: strtotime miscalculates when exiting DST with relative time
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236975@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73138&edit=1 ID: 73138 Updated by: cmb@php.net Reported by: z dot himdi at bita dot nl Summary: strtotime miscalculates when exiting DST with relative time -Status: Assigned +Status: Duplicate Type: Bug Package: Date/time related Operating System: Windows 10 PHP Version: 5.6.26 -Assigned To: derick +Assigned To: cmb Block user comment: N Private report: N New Comment: > This bug had been marked as fixed while not being fixed at all; > the test (ext/date/tests/bug30532.phpt) is using the *actual* > result instead of the *expected* result in the --EXPECT-- section, > for some reason? Yes, because there are *two* 2004-10-31T02:00:00 for America/New_York; which one should be chosen? In this case 2004-10-31T02:00:00-0400 would be the preferable choice, but this is not how ext/date nor Gnu date works: $ TZ=America/New_York date -d'2004-10-31 +2 hours' -Iseconds 2004-10-31T01:00:00-05:00 Blame that on DST which is the wrong way to address the problem. Anyhow, there was a related fix for the other report in PHP 5.1.0[1] regarding the first section. Other than that, this is a duplicate of bug #68549. [1] <https://3v4l.org/B2S2K> Previous Comments: ------------------------------------------------------------------------ [2016-09-21 20:35:12] bwoebi@php.net Related to bug #30532 This bug had been marked as fixed while not being fixed at all; the test (ext/date/tests/bug30532.phpt) is using the *actual* result instead of the *expected* result in the --EXPECT-- section, for some reason? Most crucially: echo date('r', strtotime('+ 0 second', 1477789199)); outputs: Sun, 30 Oct 2016 02:59:59 +0100 which is ... exactly one hour later, while we, in fact, did not change anything to the time. (I very much hope "+ 0 second" is supposed to be a no-op!) ------------------------------------------------------------------------ [2016-09-21 17:28:35] z dot himdi at bita dot nl Description: ------------ strtotime does not calculate correctly when adding or subtracting time relatively while exiting DST. Test script: --------------- date_default_timezone_set("Europe/Amsterdam"); echo strtotime('+ 1 second', 1477789199); // exiting DST in October, echoes 1477792800 in stead of 1477789200 echo strtotime('+ 1 second - 1 second', 1477789199); // exiting and re-entering DST, echoes 1477792799 in stead of 1477789199 echo strtotime('- 1 second', 1459040400); // exiting DST in March, echoes 1459043999 in stead of 1459040399 Expected result: ---------------- see the comments in the test script Actual result: -------------- one hour of unwanted difference ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73138&edit=1

« previous php.bugs (#236975) next »