Bug #63740 [Csd]: strtotime seems to use both sunday and monday as start of week

From: Date: Wed, 18 May 2016 11:21:11 +0000
Subject: Bug #63740 [Csd]: strtotime seems to use both sunday and monday as start of week
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201179@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63740&edit=1

 ID:                 63740
 Updated by:         derick@php.net
 Reported by:        salmanarshad2000 at yahoo dot com
 Summary:            strtotime seems to use both sunday and monday as
                     start of week
 Status:             Closed
 Type:               Bug
 Package:            Date/time related
 PHP Version:        5.4.9
-Assigned To:        
+Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

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.

Fixed for PHP 5.6.22, PHP 7.0.7 and PHP 7.1-dev


Previous Comments:
------------------------------------------------------------------------
[2016-05-18 11:20:16] derick@php.net

Automatic comment on behalf of github@derickrethans.nl
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f43f6fc39b92796aa934d4ae13675bb144d23435
Log: Fixed bug #63740 (strtotime seems to use both sunday and monday as start of week)

------------------------------------------------------------------------
[2016-05-18 08:51:30] derick@php.net

This is indeed a bug. It should do weeks from Monday to Sunday, and hence, in:

Sat 2015-07-04 00:00 → Mon 2015-06-29 00:00
Sun 2015-07-05 00:00 → Mon 2015-07-06 00:00
Mon 2015-07-06 00:00 → Mon 2015-07-06 00:00
Tue 2015-07-07 00:00 → Mon 2015-07-06 00:00
Wed 2015-07-08 00:00 → Mon 2015-07-06 00:00
Thu 2015-07-09 00:00 → Mon 2015-07-06 00:00
Fri 2015-07-10 00:00 → Mon 2015-07-06 00:00
Sat 2015-07-11 00:00 → Mon 2015-07-06 00:00
Sun 2015-07-12 00:00 → Mon 2015-07-13 00:00
Mon 2015-07-13 00:00 → Mon 2015-07-13 00:00
Tue 2015-07-14 00:00 → Mon 2015-07-13 00:00

The following are wrong:

Sun 2015-07-05 00:00 → Mon 2015-07-06 00:00
Sun 2015-07-12 00:00 → Mon 2015-07-13 00:00

I'll investigate.

------------------------------------------------------------------------
[2016-05-17 22:34:34] mateusz dot m dot nowaczyk at gmail dot com

I spent hours of scratching my head and analyzing SQL queries because of this bug - some financial
reports were incorrectly calculated due to this behavior. I eventually implemented some ugly
workaround. Why isn't this fixed, after three years?

------------------------------------------------------------------------
[2016-02-03 10:30:09] szeli dot zsolt at hotmail dot com

similar problem ... when get actual week first and last day.
first day is: strtotime('this week last monday')
last day is: strtotime('this week next sunday') is coming back to the next week on sunday,
so have to strtotime('this week last monday + 6 days')

------------------------------------------------------------------------
[2015-07-13 09:51:53] mrtreinis at gmail dot com

This is a rather horrible bug, bumping for pressure. 

Another test sample: 

(date)->modify('Monday this week')

2015-07-06: 2015-07-06 // Mo - Mo
2015-07-07: 2015-07-06 // Tu - Mo
2015-07-08: 2015-07-06 // We - Mo
2015-07-09: 2015-07-06 // Th - Mo
2015-07-10: 2015-07-06 // Fr - Mo
2015-07-11: 2015-07-06 // Sa - Mo
2015-07-12: 2015-07-13 // Su - Mo next week???!!!

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=63740


--
Edit this bug report at https://bugs.php.net/bug.php?id=63740&edit=1


Thread (12 messages)

« previous php.bugs (#201179) next »