php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40702 Microtime Not Working Properly
Submitted: 2007-03-03 06:02 UTC Modified: 2007-03-03 06:12 UTC
From: noah at rave dot ca Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.1 OS: Windows
Private report: No CVE-ID: None
 [2007-03-03 06:02 UTC] 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]

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-03 06:04 UTC] noah at rave dot ca
Sorry my mistake...
 [2007-03-03 06:08 UTC] 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:12 UTC] noah at rave dot ca
I'm going to sleep missing (true)...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC