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

 ID:                 62211
 Updated by:         ras...@php.net
 Reported by:        alix dot axel at gmail dot com
 Summary:            Weekdays with strtotime
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Please use a current version of PHP. 5.2.5 is from 2007. 
This is the output I get:

string(10) "5.3.15-dev"
string(21) "2012-05-31 (Thursday)"
string(21) "2012-06-07 (Thursday)"
string(19) "2012-06-11 (Monday)"
string(20) "2012-06-12 (Tuesday)"
string(22) "2012-06-13 (Wednesday)"
string(19) "2012-06-01 (Friday)"
string(19) "2012-06-08 (Friday)"
string(20) "2012-06-12 (Tuesday)"
string(22) "2012-06-13 (Wednesday)"
string(21) "2012-06-14 (Thursday)"


Previous Comments:
------------------------------------------------------------------------
[2012-06-02 01:55:30] alix dot axel at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=62211&edit=1

Reply via email to