#47735 [NEW]: strtotime "weekday" keyword yields false results on weekends
From: jmccombs at bloosky dot com
Operating system: Windows XP
PHP version: 5.2.9
PHP Bug Type: Date/time related
Bug description: strtotime "weekday" keyword yields false results on weekends
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 bug report at http://bugs.php.net/?id=47735&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47735&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47735&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47735&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47735&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47735&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47735&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47735&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47735&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47735&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47735&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47735&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47735&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47735&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47735&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47735&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47735&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47735&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47735&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47735&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47735&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47735&r=mysqlcfg
Thread (3 messages)
- jmccombs at bloosky dot com