Bug #80308 [Com]: strtotime() issue with Nov 1st

From: Date: Tue, 03 Nov 2020 01:09:28 +0000
Subject: Bug #80308 [Com]: strtotime() issue with Nov 1st
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230076@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80308&edit=1 ID: 80308 Comment by: safa_al18 at hotmail dot com Reported by: bruno at leveque dot io Summary: strtotime() issue with Nov 1st Status: Not a bug Type: Bug Package: *General Issues Operating System: Ubuntu 20.04.1 LTS PHP Version: 7.4.12 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2020-11-02 23:17:30] 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-02 22:56:04] 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 22:47:17] 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:45:07] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80308&edit=1

« previous php.bugs (#230076) next »