php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26154 day of week modifier on real date produced unexpected result
Submitted: 2003-11-06 12:52 UTC Modified: 2003-11-06 17:15 UTC
From: tnelson at wticorp dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.3 OS: RedHat Linux 9.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tnelson at wticorp dot com
New email:
PHP Version: OS:

 

 [2003-11-06 12:52 UTC] tnelson at wticorp dot com
Description:
------------
The day of week modifier when used with a "real" date does not advance to that day of the week. I expected that the "explicit mention of a day of the week will forward the date (only if necessary) to reach that day of the week in the future."

The source of this expectation (aside from the fact that "next friday" worked when I tried it) is the "Day of Week Item" section in the GNU manual page referenced from the strtotime function documentation.

http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html

"next week friday" works as expected

"+3 weeks friday" works as expected 

"dec 25 friday" does not work as expected. Instead it returns Thursday December 25, 2003

"dec 25 +1 week friday" also does not work as expected. Instead it returns Thursday January 1, 2004 



Reproduce code:
---------------
echo date("l F j, Y ", strtotime("dec 25 friday");


Expected result:
----------------
Expected 

Friday December 26, 2003


Actual result:
--------------
produces...

Thursday December 25, 2003

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-06 14:32 UTC] sniper@php.net
You really can't throw strtotime just anything and expect it to work. Notice the words 'try' and 'about any' in the manual for this function..

 [2003-11-06 17:15 UTC] tnelson at wticorp dot com
Could we make this a feature request as opposed to a "bogus bug" then?

In the case of "dec 25 friday" the Day of Week Item isn't flagged an error; it is completely ignored, as if the friday was not even there.

As for consistency with current strtotime functionality, the aforementioned "Day of Week Item" documentation implies what its behaviour should be and from a specification point of view it is unambiguous.

I ask again because there is no way to simply 'throw' strtotime the question:

"Give me the friday after december 25th"

unless I do it with an ugly workaound in two steps as in:
 
strtotime("friday",strtotime("dec 25"));
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 01 21:01:29 2024 UTC