Edit report at https://bugs.php.net/bug.php?id=62507&edit=1
ID: 62507 Updated by: fel...@php.net Reported by: theultramage at gmail dot com Summary: $_SERVER['REQUEST_TIME'] under mod_php5 returns miliseconds instead of seconds -Status: Open +Status: Closed Type: Bug Package: Apache2 related PHP Version: 5.4.4 -Assigned To: +Assigned To: felipe Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. 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/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2012-07-08 17:07:06] fel...@php.net Automatic comment on behalf of felipe...@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=2019062cfc6e4b4832aaca3b73891d93adc115a8 Log: - Fixed bug #62507 (['REQUEST_TIME'] under mod_php5 returns miliseconds instead of seconds) ------------------------------------------------------------------------ [2012-07-08 13:30:07] theultramage at gmail dot com Description: ------------ http://git.php.net/?p=php-src.git;a=commitdiff;h=f89effd2a83de2b1d6381f9b9403a8328e0998b6 On 6.nov.2010 Ilia Alshanetsky "Updated _SERVER['REQUEST_TIME'] to include microsecond precision". This introduced a breaking change - since then variable returns miliseconds instead of seconds. http://git.php.net/?p=php-src.git;a=commitdiff;h=86c44e119fd71eeed6f3bc213d544a06cc4a13e5 On 23.jun.2011 someone finally noticed, and he "Fixed a bug with calculation of REQUEST_TIME in apache2". However, he only fixed apache2handler and omitted apache2filter. The bug breaks existing code that uses $_SERVER['REQUEST_TIME'] in timestamp comparisons and assumes that its value is in seconds. I tested the attached patch and it fixes the issue (hopefully not introducing other issues). PS: $_SERVER['REQUEST_TIME_FLOAT'] is also affected. Test script: --------------- <?php $rt = $_SERVER['REQUEST_TIME']; $now = time(); echo $rt."\n"; echo $now."\n"; echo ( strlen((string)$rt) == strlen((string)$now) ) ? "OK" : "Error!"; ?> Expected result: ---------------- 1341752154 1341752154 OK Actual result: -------------- CLI/CGI: 1341752154 1341752154 OK MOD_PHP5: 1341752154539 1341752154 Error! ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62507&edit=1