php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80308 strtotime() issue with Nov 1st
Submitted: 2020-11-02 22:45 UTC Modified: 2020-11-02 23:17 UTC
From: bruno at leveque dot io Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.4.12 OS: Ubuntu 20.04.1 LTS
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bruno at leveque dot io
New email:
PHP Version: OS:

 

 [2020-11-02 22:45 UTC] bruno at leveque dot io
Description:
------------
strtotime() is encountering issues when dealing with Nov 1st, 2020 specifically.

- Adding 2 x 86400 seconds to Nov 1st will actually return Nov 2nd
- Adding '+2 days' to the same date returns Nov 3rd

This issue does not happen with any other date.

Test script:
---------------
<?php

/* Add 2 days to Oct 1st
** Outputs 2020-10-03 - Correct
*/
echo strftime('%Y-%m-%d', strtotime('2020-10-01') + (2 * 86400))."\n";

/* Add 2 days to Nov 1st
** Outputs 2020-11-02 - Bug
*/
echo strftime('%Y-%m-%d', strtotime('2020-11-01') + (2 * 86400))."\n";

/* Add 2 days to Nov 1st
** Outputs 2020-11-03 - Correct
*/
echo strftime('%Y-%m-%d', strtotime('2020-11-01 + 2 days'))."\n";

Expected result:
----------------
2020-10-03
2020-11-03
2020-11-03

Actual result:
--------------
2020-10-03
2020-11-02
2020-11-03

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-02 22:47 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2020-11-02 22:47 UTC] requinix@php.net
Apparently you're in one of the timezones where 2020-11-01 was more than 86400 seconds long.
 [2020-11-02 22:56 UTC] bruno at leveque dot io
I understand that the Daytime Savings Time change could be at play however why wouldn't this apply to '+2 days' as well?.
 [2020-11-02 23:17 UTC] requinix@php.net
+2 days means literally +2 days, and 11-01 + 2 days = 11-03. The length of those days has no bearing on (this) math.
 [2020-11-03 01:09 UTC] safa_al18 at hotmail dot com
i asked this issue from
https://stackoverflow.com/questions/64655031/php-says-everyday-have-diffrent-seconds-for-time-zone
some users says 
"We changed from daylight time to standard time on November 1. There was an extra hour that morning. "
thats great php calculated this.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC