php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #46932 strtotime() has inconsistency between 'next Monday' and '+1 Monday'
Submitted: 2008-12-23 06:18 UTC Modified: 2009-09-15 06:52 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: for-bugs at hnw dot jp Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.8 OS: any
Private report: No CVE-ID: None
 [2008-12-23 06:18 UTC] for-bugs at hnw dot jp
Description:
------------
With PHP 5.2.8 or 5.3.0alpha3, 'next Monday' and '+1 Monday' is diffrenet. On Monday, 'next Monday' seems the same day. However, '+1 Monday' means 1 week later.

'next day' and '+1 day' performs the same behavior, so it is natural to me that 'next Monday' and '+1 Monday' is the same meanings.

In addition, my GNU date command never accept '+1 Monday' and 'next Monday' on Monday means the same day. So, I cannot tell what is the right behavior. I only report inconsistency.

Reproduce code:
---------------
<?php
var_dump(date("Y-m-d",strtotime("+1 Monday 2008-12-01")));
var_dump(date("Y-m-d",strtotime("next Monday 2008-12-01")));


Actual result:
--------------
string(10) "2008-12-01"
string(10) "2008-12-08"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-23 14:14 UTC] derick@php.net
5.3 does the proper behavior.
 [2009-01-15 08:39 UTC] for-bugs at hnw dot jp
How about PHP 5.2.8? PHP 5.2.8 also does same behavior.

I think this behavior is introduced by fix #43452.

http://bugs.php.net/bug.php?id=43452

The bug ticket has been closed, but this confused behaviour is not documented.
 [2009-05-11 08:50 UTC] jani@php.net
Both PHP_5_2 and PHP_5_3 output same now.
 [2009-09-15 06:28 UTC] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=288346
Log: Documented the old incorrect behaviour that requesting a given
occurrence of a weekday in a month when that weekend occurred on the
first day of the month would add one week to the returned timestamp.

Addresses bug #46932

Not sure this should be a warning. Seems more appropriate in the
changelog section. I'm just putting it here now to be consistent with
the existing function reference.
 [2009-09-15 06:52 UTC] torben@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 21:01:32 2024 UTC