Bug #62211 [NEW]: Weekdays with strtotime
| From: | alix dot axel at gmail dot com | Date: | Sat, 02 Jun 2012 01:55:31 +0000 |
| Subject: | Bug #62211 [NEW]: Weekdays with strtotime | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-170988@lists.php.net to get a copy of this message | ||
From: alix dot axel at gmail dot com
Operating system: Linux
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:Weekdays with strtotime
Description:
------------
When using the relative "weekday[s]" string with strtotime() it returns
inconsistent results, sometimes the date is the correct one, but some other
times
it's wrong (it even returns weekend days).
http://codepad.org/2wYfJltN
http://stackoverflow.com/questions/10857762/php-time-periods-without-weekends
Test script:
---------------
<?php
var_dump(PHP_VERSION);
$date = strtotime('2012-05-30'); // Wednesday
var_dump(date('Y-m-d (l)', strtotime('+1 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+6 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+8 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+9 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+10 weekdays', $date)));
$date = strtotime('2012-05-31'); // Friday
var_dump(date('Y-m-d (l)', strtotime('+1 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+6 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+8 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+9 weekdays', $date)));
var_dump(date('Y-m-d (l)', strtotime('+10 weekdays', $date)));
Expected result:
----------------
string(5) "5.2.5"
string(21) "2012-05-31 (Thursday)"
string(21) "2012-06-07 (Thursday)"
string(21) "2012-06-11 (Monday)"
string(19) "2012-06-12 (Tuesday)"
string(22) "2012-06-13 (Wednesday)"
string(19) "2012-06-01 (Friday)"
string(19) "2012-06-08 (Friday)"
string(19) "2012-06-12 (Tuesday)"
string(19) "2012-06-13 (Wednesday)"
string(21) "2012-06-14 (Thursday)"
Actual result:
--------------
string(5) "5.2.5"
string(21) "2012-05-31 (Thursday)"
string(21) "2012-06-07 (Thursday)"
string(21) "2012-06-09 (Saturday)"
string(19) "2012-06-10 (Sunday)"
string(22) "2012-06-13 (Wednesday)"
string(19) "2012-06-01 (Friday)"
string(19) "2012-06-08 (Friday)"
string(19) "2012-06-10 (Sunday)"
string(19) "2012-06-11 (Monday)"
string(21) "2012-06-14 (Thursday)"
--
Edit bug report at https://bugs.php.net/bug.php?id=62211&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62211&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62211&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62211&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=62211&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62211&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=62211&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=62211&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=62211&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=62211&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=62211&r=support
Expected behavior: https://bugs.php.net/fix.php?id=62211&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=62211&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=62211&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=62211&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62211&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=62211&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=62211&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=62211&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=62211&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=62211&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=62211&r=mysqlcfg