|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13142 strtotime() returns -1 for "M d H:i:s Y" format
Submitted: 2001-09-04 16:47 UTC Modified: 2003-07-27 23:03 UTC
Avg. Score:4.3 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:1 (20.0%)
From: jeannielu at hotmail dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 4.3.0-dev OS: Linux
Private report: No CVE-ID: None
 [2001-09-04 16:47 UTC] jeannielu at hotmail dot com
strtotime("Sep 04 16:39:45 2001") returns -1 with PHP 4.0.6

this was working with PHP 4.0.3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-11 09:13 UTC] godin dot gilles at ic dot gc dot ca
I am using PHP 4.2.3 under Windows 2000 where

date("D M d H:i:s T Y") produces...
Fri Oct 11 09:52:47 Eastern Standard Time 2002
instead of...
Fri Oct 11 09:52:47 EDT 2002

and, strtotime() of either format produced above returns -1
 [2003-01-02 19:34 UTC]
Verified again with 4.3.0.
 [2003-04-07 14:40 UTC] jparneodo at yahoo dot fr
Same problem on RedHat 7.2
with PHP 4.3.0
on CEST timezone
returns -1
 [2003-04-19 16:49 UTC] fh at fuenf-freun dot de
The problem is that the argument is ambigous.

"M d H:i:s Y"

could also be interpreted as

"M d Y:i:s Y".

The latter case happens when PHP parses the string. Then a parse error occurs, because ':i:s' doesn't make any sense. Therefore, the function returns -1.
In ext/standard/parsedate.y, the expression "M d H:i:s Y" is matched by 'tUNUMBER tMONTH tUNUMBER' (M d H) as well as 'tUNUMBER : tUNUMBER : tUNUMBER' (H:i:s).
Unfortunately, I am not able to submit a patch as I know nothing about lex/yacc.

 [2003-07-27 23:03 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 21:01:28 2023 UTC