|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
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! --cpYes 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()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.