php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48699 $date->modify('+ 1 '. $date->format('l')) == $date
Submitted: 2009-06-26 10:48 UTC Modified: 2009-06-29 12:10 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mehdi dot rande at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.10 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mehdi dot rande at gmail dot com
New email:
PHP Version: OS:

 

 [2009-06-26 10:48 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-26 12:22 UTC] derick@php.net
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-29 12:10 UTC] mehdi dot rande at gmail dot com
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.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 09:01:29 2025 UTC