[thelist] RE: Calculating Times in PHP

jon steele jjsteele22 at yahoo.com
Mon Jun 11 18:43:28 CDT 2001


Hi Daryl,

Try subtracting the timestamp time first, before formatting it in any
way.

Jon.
----------------------------------------------------
"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"
--------------------------------------


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/




More information about the thelist mailing list