#47735 [Opn->Fbk]: strtotime "weekday" keyword yields false results on weekends

From: Date: Fri, 18 Sep 2009 19:03:09 +0000
Subject: #47735 [Opn->Fbk]: strtotime "weekday" keyword yields false results on weekends
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-142545@lists.php.net to get a copy of this message
ID: 47735 Updated by: jani@php.net Reported By: jmccombs at bloosky dot com -Status: Open +Status: Feedback Bug Type: Date/time related Operating System: Windows XP PHP Version: 5.2.9 New Comment: Please try using this snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Previous Comments: ------------------------------------------------------------------------ [2009-03-20 17:17:53] jmccombs at bloosky dot com Description: ------------ In strtotime, using the keyword "weekday" to calculate a date yields false results when: - starting from a weekend date (including Friday) - AND end date lands on a weekend Reproduce code: --------------- <?php echo date("Y-m-d", strtotime("2009-03-20 +5 weekday"))."\n"; //EXPECT: 2009-03-27. RETURNS: 2009-03-29 echo date("l", strtotime("friday +5 weekday"))."\n"; //EXPECT: "Friday". RETURNS: "Sunday" ## Works fine as long as start date is not a weekend... echo date("l", strtotime("thursday +6 weekday"))."\n"; //EXPECT: "Friday". RETURNS: "Friday" ## ...OR end date does not land on weekend: echo date("l", strtotime("friday +4 weekday"))."\n"; //EXPECT: "Thursday". RETURNS: "Thursday" ?> Expected result: ---------------- 2009-03-27 Friday Friday Thursday Actual result: -------------- 2009-03-29 Sunday Friday Thursday ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47735&edit=1

« previous php.bugs (#142545) next »