Edit report at https://bugs.php.net/bug.php?id=63521&edit=1
ID: 63521
Comment by: nabil at thinkshirt dot com
Reported by: linesarefuzzy at gmail dot com
Summary: Adding 5 weekdays to Fri, Sat or Sun results in
Sunday
Status: Open
Type: Bug
Package: Date/time related
Operating System: Mac, Linux
PHP Version: 5.3.18
Block user comment: N
Private report: N
New Comment:
I am still having this issue. +10 and +5 give me the following Sunday instead of Friday on PHP
5.4.29.
Previous Comments:
------------------------------------------------------------------------
[2013-04-19 06:41:21] ravgu10 at gmail dot com
There is one more issue.
date('Y-m-d',strtotime(date('Y-m-d', strtotime('2013-04-22' . "
+5 Weekday"))));
Expected result: 2013-04-29 (Monday)
Actual result:2013-04-29 (Monday)
fine but when u do,
date('Y-m-d',strtotime(date('Y-m-d', strtotime('2013-04-29' . "
-5 Weekday"))));
Expected result: 2013-04-22 (Monday)
Actual result:2013-04-20 (Saturday)
------------------------------------------------------------------------
[2013-03-02 14:04:48] payden at paydensutherland dot com
This has been fixed (some time ago, Jul 29, in git). It's currently in the
latest 5.5-dev. It's not currently in latest 5.4, but I guess it should probably
make it there sometime.
------------------------------------------------------------------------
[2012-12-28 10:42:37] michal dot kocztorz at polcode dot pl
Seems to affect DateTime::modify too.
$dt = new DateTime("2013-01-04"); echo $dt->modify("+5
weekdays")->format("Y-m-d
H:i:s l") . "<br/>";
$dt = new DateTime("2013-01-05"); echo $dt->modify("+5
weekdays")->format("Y-m-d
H:i:s l") . "<br/>";
$dt = new DateTime("2013-01-06"); echo $dt->modify("+5
weekdays")->format("Y-m-d
H:i:s l") . "<br/>";
$dt = new DateTime("2013-01-07"); echo $dt->modify("+5
weekdays")->format("Y-m-d
H:i:s l") . "<br/>";
Got:
2013-01-13 00:00:00 Sunday
2013-01-13 00:00:00 Sunday
2013-01-13 00:00:00 Sunday
2013-01-14 00:00:00 Monday
------------------------------------------------------------------------
[2012-11-23 02:58:58] linesarefuzzy at gmail dot com
Jon--
Since the bug always results in Sunday when it should be Friday, an
obvious workaround would be to test the weekday of the result, and
if it's Sunday, subtract two days. For example:
<?php
if (date('l', $timestamp) == 'Sunday')
$timestamp = strtotime(date('Y-m-d', $timestamp) . ' - 2 days');
?>
------------------------------------------------------------------------
[2012-11-22 08:33:11] jon dot drummond at barrowsonline dot com
Has anyone found a solution to this yet? We can not wait for a patch & need a
workaround in the mean time.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=63521
--
Edit this bug report at https://bugs.php.net/bug.php?id=63521&edit=1