|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29557 strtotime error
Submitted: 2004-08-07 00:10 UTC Modified: 2004-11-15 17:33 UTC
Avg. Score:4.6 ± 1.0
Reproduced:13 of 13 (100.0%)
Same Version:5 (38.5%)
Same OS:3 (23.1%)
From: javier at evaloportunidades dot insp dot mx Assigned: derick (profile)
Status: Closed Package: *General Issues
PHP Version: 5.0.0 OS: Debian GNU/Linux 3.0 2.6.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 + 29 = ?
Subscribe to this entry?

 [2004-08-07 00:10 UTC] javier at evaloportunidades dot insp dot mx
   We use the strtotime function to get a value that is used as primary key on a database table. But with PHP 5.0.0 the strtotime function is returning duplicate values.

    Here is the configure line:
'./configure' '--disable-cli' '--disable-cgi' '--without-pear' '--without-mysql' '--with-pgsql' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-memory-limit'

    With PHP 4 we didn't face this problem.



Reproduce code:
for ($i=0;$i<10;$i++)
	$aux = strtotime("now");
	echo $aux ."<br>";

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-08 23:04 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

The code takes <1 second to run, so of course the timestamp 
with 1 second precision will be the same. 
 [2004-08-09 09:12 UTC] javier at evaloportunidades dot insp dot mx
But the problem is that even after n seconds with PHP 5.0.0 I get the same result.
 [2004-08-09 09:33 UTC]
"now" returns midnight of the current day. I think this is wrong too.
 [2004-08-23 06:01 UTC] cplee at buzzcity dot com
The problem still exists in 5.0.1! Anyway, the problem lies in some "conditions" being commented in the ext/standard/parsedate.y (and parsedate.c) under the php_parse_date() function. (parsedate.y:1082, parsedate.c: 2325). I basically uncomment those lines and did a recompile. Now the following command gives the correct result:

php -r 'echo strtotime("now");'


Hope this helps!

 [2004-08-24 09:34 UTC] never_slept at yahoo dot com
Yes I read that bug report and although them sounded to potentially be the same thing... my strtotime("now") does in fact spit out a different value every second and that bug report makes no mention of using the second argument for strtotime()
 [2004-09-12 02:05 UTC] javier at evaloportunidades dot insp dot mx
Thanks cp, I uncommented the part of the condition in the lines you said, recompile php, and it worked. This is the part of the condition:

|| (date.yyHaveRel && !date.yyHaveDate && !date.yyHaveDay)

    Does anybody know why this part of the condition is commented??

  After recompiling php whith these lines uncommented, the strtotime("now") returns a different value every second (as it should be):


    Thank you very much,

    Javier Carlos R.
 [2004-11-15 17:33 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 11 19:01:30 2020 UTC