ID: 48187 Updated by: j...@php.net Reported By: wavetrex at gmail dot com -Status: Open +Status: Feedback Bug Type: Date/time related Operating System: Windows 2003 Server PHP Version: 5.3.0RC2 New Comment:
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)); ?> Previous Comments: ------------------------------------------------------------------------ [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