php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69529 strtotime fix
Submitted: 2015-04-24 21:34 UTC Modified: 2015-04-24 22:23 UTC
From: serella_c at hotmail dot com Assigned:
Status: Wont fix Package: Date/time related
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
 [2015-04-24 21:34 UTC] serella_c at hotmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.strtotime
---

Im wondering if there is ever going to be a fix for what i consider to be a bug.

It wouldnt be acceptable to iterate over an array and when asking for next and last the result being best guessed so i dont see why this is any different.

We should not have to resort to calling strtotime with a date in the middle of the month then adjust the date required thats just a hack and this has been a known issue for several years, its time to fix strtotime.

Expected result:
----------------
strtotime should return what is asked of it.

If i ask for last month it should return last month regardless of the day in the month be it the 31st, 15th or 1st the result should be the same. across the board.

Likewise for next month, years etc. It is quite clear that when asking for next or last of something we really do mean the next or last regardless of day numbers involved.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-24 22:07 UTC] rasmus@php.net
-Status: Open +Status: Wont fix
 [2015-04-24 22:07 UTC] rasmus@php.net
For better or worse there are two approaches to date math like this. PHP conforms to the normal UNIX approach as exhibited by your command line GNU date command, sqlite and several other tools. Whether or not this is the best approach has been argued back and forth for a decade, but it certainly isn't a bug and we are not going to suddenly swap it to the other approach.

You can read more here: http://www.gnu.org/software/tar/manual/html_node/Relative-items-in-date-strings.html#SEC120
and here:
http://www.sqlite.org/lang_datefunc.html
 [2015-04-24 22:23 UTC] cmb@php.net
-Package: *General Issues +Package: Date/time related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC