#48699 [Bgs]: $date->modify('+ 1 '. $date->format('l')) == $date

[email protected] ("mehdi dot rande at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               48699
 User updated by:  mehdi dot rande at gmail dot com
 Reported By:      mehdi dot rande at gmail dot com
 Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Linux
 PHP Version:      5.2.10
 New Comment:

I've triple checked the doc, it seems to make reference to the gnu
input date format. gnu date command behave like this :
$ date --version
date (GNU coreutils) 7.4
$ date
Mon Jun 29 14:05:30 CEST 2009
$ date -s "1 monday" +%F
2009-07-06
$ date -s "next monday" +%F
2009-07-06

But it's true that this bug is a duplicate of #46932 wich still open,
so sorry for the noise.


Previous Comments:
------------------------------------------------------------------------

[2009-06-26 12:22:04] [email protected]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.

------------------------------------------------------------------------

[2009-06-26 10:48:33] mehdi dot rande at gmail dot com

Description:
------------
Since php 5.2.9 modify function behaviour have change, in both case
"next $weekday" always go to the next specified weekday ("next weekday"
> "today"), but in 5.2.9 and 5.2.10 "+1 $weekday" go to the first
encoutered specified weekday including today ("next weekday" >=
"today"). 

The behaviour of older php versions seems more logical to me, '+1'
should have the same behaviour than 'next'.

Reproduce code:
---------------
// Since php 5.2.9
$date  = new Datetime("2009-06-01");
$date->modify("+1 ".$date->format("l")); // == ('+1 monday')
echo $date->format("Y-m-d")."\n"; 
$date->modify("next ".$date->format("l")); // == ('next monday')
echo $date->format("Y-m-d")."\n"; 


Expected result:
----------------
2009-06-08
2009-06-08

Actual result:
--------------
2009-06-01
2009-06-08


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48699&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.