From: salmanarshad2000 at yahoo dot com Operating system: PHP version: 5.4.9 Package: Date/time related Bug Type: Bug Bug description:strtotime seems to use both sunday and monday as start of week
Description: ------------ Weeks start on Sunday or Monday. However, in this regard: 1) strtotime behavior is not documented. 2) strtotime produces inconsistent results when "this week" is used. Sample dates from month of December 2012 used the the test script: Mon 2012-12-03 Tue 2012-12-04 Wed 2012-12-05 Thu 2012-12-06 Fri 2012-12-07 Sat 2012-12-08 Sun 2012-12-09 Mon 2012-12-10 Tue 2012-12-11 Wed 2012-12-12 Thu 2012-12-13 Fri 2012-12-14 Sat 2012-12-15 Sun 2012-12-16 Test script: --------------- // function strtotime called on Sun 2012-12-09 echo date("D Y-m-d", strtotime("monday this week", strtotime("2012-12-09"))); // Mon 2012-12-10 echo date("D Y-m-d", strtotime("sunday this week", strtotime("2012-12-09"))); // Sun 2012-12-16 // function strtotime called on Mon 2012-12-10 echo date("D Y-m-d", strtotime("monday this week", strtotime("2012-12-10"))); // Mon 2012-12-10 echo date("D Y-m-d", strtotime("sunday this week", strtotime("2012-12-10"))); // Sun 2012-12-16 Expected result: ---------------- If Sunday is start of the week then "sunday this week" be less than "monday this week": // function strtotime called on Sun 2012-12-09 echo date("D Y-m-d", strtotime("monday this week", strtotime("2012-12-09"))); // Mon 2012-12-10 echo date("D Y-m-d", strtotime("sunday this week", strtotime("2012-12-09"))); // Sun 2012-12-09 // function strtotime called on Mon 2012-12-10 echo date("D Y-m-d", strtotime("monday this week", strtotime("2012-12-10"))); // Mon 2012-12-10 echo date("D Y-m-d", strtotime("sunday this week", strtotime("2012-12-10"))); // Sun 2012-12-09 If Monday is start of the week then "monday this week" should return different values on sunday and monday: // function strtotime called on Sun 2012-12-09 echo date("D Y-m-d", strtotime("monday this week", strtotime("2012-12-09"))); // Mon 2012-12-03 echo date("D Y-m-d", strtotime("sunday this week", strtotime("2012-12-09"))); // Sun 2012-12-09 // function strtotime called on Mon 2012-12-10 echo date("D Y-m-d", strtotime("monday this week", strtotime("2012-12-10"))); // Mon 2012-12-10 echo date("D Y-m-d", strtotime("sunday this week", strtotime("2012-12-10"))); // Sun 2012-12-16 Actual result: -------------- See test script, actual result is present alongside each line. -- Edit bug report at https://bugs.php.net/bug.php?id=63740&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63740&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63740&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63740&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63740&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63740&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63740&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63740&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63740&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63740&r=support Expected behavior: https://bugs.php.net/fix.php?id=63740&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63740&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63740&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63740&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63740&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63740&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63740&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63740&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63740&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63740&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63740&r=mysqlcfg