php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74652 strtotime() does not define behaviour of h/m/s when passed only a date
Submitted: 2017-05-25 14:35 UTC Modified: 2017-05-26 12:44 UTC
From: junk at talpa dot plus dot com Assigned:
Status: Open Package: Date/time related
PHP Version: Irrelevant OS: ALL
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: junk at talpa dot plus dot com
New email:
PHP Version: OS:

 

 [2017-05-25 14:35 UTC] junk at talpa dot plus dot com
Description:
------------
strtotime() can be given a string which only represents a "date", rather than a specific second-granularity on that date, e.g.

$foo = strtotime('25 May 2017');

Since strtotime() returns a timestamp it must decide on a sensible point on that day to use. As far as I can see, all versions (sensibly) assume 00 for any missing time elements, leading the example above to return a timestamp that represents


"2017-05-25T00:00:00+00:00"

This follows through if some time elements are given, but not others, e.g. 

strtotime('25 May 2017 10pm') => "2017-05-25T22:00:00+00:00"

While it *seems* safe to rely on this behaviour, it would be better to have it as documented behaviour of strtotime().


Expected result:
----------------
Documentation clearly indicates how the sub-day elements of the timestamp are constructed in the absence of time information in the input. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-26 12:44 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Package: Documentation problem +Package: Date/time related
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sat Nov 18 09:04:14 2017 UTC