[thelist] Calculating Times in PHP

Poojie poojie at dccnet.com
Mon Jun 11 17:24:56 CDT 2001


Hello,

I'm attempting to time functions in PHP, but I keep getting
negative values. I use the following function to get the time
before and after the function I want to time has been called:

function time_now(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}

The timing code looks something like this:

$t_start = time_now();     // Start Time
func_to_time();                // Some action
$t_end = time_now();      // End Time

$t_total = $t_end  - $t_start; // Total time passed

How is it possible that roughly 1/2 of the result times turn up
negative?


Daryl





More information about the thelist mailing list