ID: 48187 User updated by: wavetrex at gmail dot com Reported By: wavetrex at gmail dot com -Status: Feedback +Status: Open Bug Type: Date/time related Operating System: Windows 2003 Server PHP Version: 5.3.0RC2 New Comment:
float(1241919300.3593) float(1241709350.3736) int(1241919300) int(1241919300) string(25) "2009-05-10T04:35:00+03:00" string(25) "2009-05-10T04:35:00+03:00" ( http://wt.ath.cx/jani.php ) Note: 1241709350 -> this value seems to stay almost unchanged over time (look at my first submission: string(21) "0.25882200 1241709345" ) When I reported the difference was ~50000 seconds, now it's over 200.000 Previous Comments: ------------------------------------------------------------------------ [2009-05-09 20:59:00] j...@php.net What is the output of the script I provided? ------------------------------------------------------------------------ [2009-05-09 06:58:21] wavetrex at gmail dot com @jani: I'm using microtime() multiple times to determine how long some complex parts of the script take to execute, when I noticed weird differences. Also, while the second microtime() call after diff() is wrong, the third seems to be ok, just like calling the function resets some internal variable that was broken during execution of diff() I prepared a script on my server: http://wt.ath.cx/diff.php The code for this script is here: http://wt.ath.cx/diff.txt Server configuration: http://wt.ath.cx/phpinfo.php Time difference between the two calls: Expected result: 3.814697265625E-5 (a few microseconds) Actual result: -142455.45035195 (??) Your script: http://wt.ath.cx/jani.php ... also has the error. If this probably occurs on my server, I'm thinking... it might be timezone related ? I'm sure yours and mine are different. (check my phpinfo.php to see date/time settings) P.S. While investigating, I noticed that in some rare cases it doesn't happen, and after Ctrl-R it gives the erroned value again. Try reloading the page a few times in case 1st time it shows the correct values. I'll keep experimenting with the new 5.3.0 time functions and see if some other errors appear. ------------------------------------------------------------------------ [2009-05-09 04:15:40] j...@php.net Try this script instead: (I can't reproduce this..) <?php // two arbitrary dates $date1=new DateTime("2005-07-23"); $date2=new DateTime("2006-02-14"); $begin_u = microtime(true); $begin_t = time(); $begin_a = date(DATE_ATOM); var_dump($date1->diff($date2)); var_dump($begin_u, microtime(true)); var_dump($begin_t, time()); var_dump($begin_a, date(DATE_ATOM)); ?> ------------------------------------------------------------------------ [2009-05-08 05:42:58] wavetrex at gmail dot com Description: ------------ calling DateTime::diff() seems to corrupt the result returned by microtime(), so it returns the wrong time after this function has been called Reproduce code: --------------- <?php // two arbitrary dates $date1=new DateTime("2005-07-23"); $date2=new DateTime("2006-02-14"); echo "<pre>"; var_dump(microtime()); var_dump(time()); var_dump(date(DATE_ATOM)); var_dump($date1->diff($date2)); var_dump(microtime()); var_dump(time()); var_dump(date(DATE_ATOM)); echo "</pre>"; ?> Expected result: ---------------- Expecting the 2nd microtime to be slightly bigger ( by a few miliseconds ) than first. instead, it's a totally wrong 50000 seconds distance (or maybe other arbitrary value) date() and time() seem to be unaffected Actual result: -------------- before calling diff: string(21) "0.98425000 1241761004" after it: string(21) "0.25882200 1241709345" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48187&edit=1