#40702 [Opn->Bgs]: Microtime Not Working Properly

From: Date: Sat, 03 Mar 2007 06:12:27 +0000
Subject: #40702 [Opn->Bgs]: Microtime Not Working Properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-109818@lists.php.net to get a copy of this message
ID: 40702 User updated by: noah at rave dot ca Reported By: noah at rave dot ca -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Windows PHP Version: 5.2.1 New Comment: I'm going to sleep missing (true)... Previous Comments: ------------------------------------------------------------------------ [2007-03-03 06:08:44] noah at rave dot ca Actually it does sometimes return negative results... Made a typo the code... <? $start_time = microtime(); RUN QUERY $end_time = microtime(); $run_time = $end_time - $start_time; echo '[' . $end_time . '] - [' . $start_time . '] = [' . $run_time . ']'; ?> Results: [0.78013100 1172901980] - [0.64630700 1172901980] = [0.133824] [0.01399700 1172902065] - [0.88014400 1172902064] = [-0.866147] [0.87408300 1172902076] - [0.66131900 1172902076] = [0.212764] [0.46581000 1172902112] - [0.97359300 1172902111] = [-0.507783] ------------------------------------------------------------------------ [2007-03-03 06:04:21] noah at rave dot ca Sorry my mistake... ------------------------------------------------------------------------ [2007-03-03 06:02:17] noah at rave dot ca Description: ------------ When subtracting endtime from start time gets a negative number... Reproduce code: --------------- <? $start_time = microtime(); $end_time = microtime(); $run_time = $time_end - $start_time; echo '[' . $end_time . '] - [' . $start_time . '] = [' . $run_time . ']'; ?> Expected result: ---------------- A positive number... Actual result: -------------- [0.13353900 1172901538] - [0.13351700 1172901538] = [-0.133517] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40702&edit=1

« previous php.bugs (#109818) next »