php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18769 strtotime('00:01am'); returns -1 instead of timestamp
Submitted: 2002-08-07 04:01 UTC Modified: 2002-08-07 04:27 UTC
From: peka at yashuu dot de Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.2.2 OS: Tested on Windows2000 / Unix
Private report: No CVE-ID: None
 [2002-08-07 04:01 UTC] peka at yashuu dot de
The PHP code
<?
echo strtotime('00:01am');
?>
produces -1 as return instead of a correct timestamp

I tested on W2k/Apache/PHP 4.2.2, afterwards uploading it to my webspace provider who uses Unix. The bug is reproduceable there, too.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-07 04:18 UTC] eru@php.net
This is quite correct, as 0 isn't a valid hour in this time-format. To quote from date input formats:

If the time is followed by `am' or `pm' (or `a.m.' or `p.m.'), hour is restricted to run from 1 to 12, and `:minute' may be omitted (taken to be zero). `am' indicates the first half of the day, `pm' indicates the second half of the day. In this notation, 12 is the predecessor of 1: midnight is `12am' while noon is `12pm'. 

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

 [2002-08-07 04:27 UTC] peka at yashuu dot de
So maybe there should be 2 different error states?

one for unrecogniseable string
one for recognised string, but incorrect time-format
If those two could be distinguished
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 17:01:33 2024 UTC