|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73138 strtotime miscalculates when exiting DST with relative time
Submitted: 2016-09-21 17:28 UTC Modified: 2016-09-21 20:35 UTC
From: z dot himdi at bita dot nl Assigned: derick (profile)
Status: Assigned Package: Date/time related
PHP Version: 5.6.26 OS: Windows 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: z dot himdi at bita dot nl
New email:
PHP Version: OS:


 [2016-09-21 17:28 UTC] z dot himdi at bita dot nl
strtotime does not calculate correctly when adding or subtracting time relatively while exiting DST.

Test script:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-21 20:35 UTC]
-Status: Open +Status: Assigned -Package: *General Issues +Package: Date/time related -Assigned To: +Assigned To: derick
 [2016-09-21 20:35 UTC]
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));


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!)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 26 22:03:37 2021 UTC