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
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: serella_c at hotmail dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 08 01:05:45 2022 UTC