php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74057 wrong day when using "this week" in strtotime
Submitted: 2017-02-07 15:52 UTC Modified: 2017-02-12 20:21 UTC
From: tony at brix dot ninja Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.6.30 OS: Windows 10
Private report: No CVE-ID: None
 [2017-02-07 15:52 UTC] tony at brix dot ninja
Description:
------------
strtotime gives inconsistent results when using "this week" due to the commit at 

https://git.php.net/?p=php-src.git;a=blobdiff;f=ext/date/lib/tm2unixtime.c;h=57e0cef1be61956874402c02799ea25a8da0d60c;hp=414cf1308200dd066c7e7d8212d6d6591de38ac0;hb=f43f6fc39b92796aa934d4ae13675bb144d23435;hpb=0815f7f755a6248b4b28163e09cbc1c91b15664b

Test script:
---------------
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sun 2017-01-01")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Mon 2017-01-02")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Tue 2017-01-03")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Wed 2017-01-04")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Thu 2017-01-05")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Fri 2017-01-06")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sat 2017-01-07")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sun 2017-01-08")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Mon 2017-01-09")))."\n";

Expected result:
----------------
Sat 2016-12-31
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-14

Actual result:
--------------
Mon 2016-12-26
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Mon 2017-01-02
Sat 2017-01-14

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-07 16:20 UTC] derick@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2017-02-10 14:48 UTC] derick@php.net
I have a patch, but collecting a few more before I push out a new version of timelib to merge into PHP.
 [2017-02-12 20:21 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2017-02-12 20:21 UTC] derick@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC