PHP :: Bug #29557 :: strtotime error

Bug #29557 strtotime error
Submitted: 2004-08-07 00:10 UTC Modified: 2004-11-15 17:33 UTC
Votes:14
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

 [2004-08-07 00:10 UTC] javier at evaloportunidades dot insp dot mx

Description:
------------
   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.


    Cheers,

    Javier



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

Actual result:
--------------
1091768400
1091768400
1091768400
1091768400
1091768400
1091768400
1091768400
1091768400
1091768400
1091768400

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [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] derick@php.net

"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:

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

Result:
1093234981

Hope this helps!

--cp

 [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):

1094947473
1094947474
1094947475
1094947476


    Thank you very much,

    Javier Carlos R.

 [2004-11-15 17:33 UTC] derick@php.net

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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.