Page 1 of 1
Strange results with script execution time
Posted: Sat Jun 30, 2007 4:34 pm
by toasty2
I'm getting strange results like 7.5101852416992E-005 with the following code:
Code: Select all
<?php
$t1 = explode(' ',microtime());
$t1 = $t1[1] + $t1[0];
// Do stuff
$t2 = explode(' ', microtime());
$t = ($t2[1] + $t2[0]) - $t1;
echo $t;
?>
(That is my real script) The same code worked fine on a bigger script. (On a bigger script I get 0.00052094459533691)
Posted: Sat Jun 30, 2007 4:48 pm
by Gente
7.5101852416992E-005 = 0.000075101852416992
Posted: Sat Jun 30, 2007 4:54 pm
by Benjamin
I asked about this last night. Use number_format() to format the result.
Posted: Sat Jun 30, 2007 5:15 pm
by toasty2
number_format() gives me 0
Posted: Sat Jun 30, 2007 5:19 pm
by John Cartwright
How did you use number format? Did you read the manual?
Posted: Sat Jun 30, 2007 5:23 pm
by superdezign
What parameters did you use in number_format?
Posted: Sat Jun 30, 2007 5:28 pm
by toasty2
None except for the number. Now I realize that will show up as 0 (no decimals). I'm not really sure how to use number_format(), the manual only explains the aesthetics for showing numbers, I just want it to be converted to a readable number (such as 0.0025354436 etc).
Posted: Sat Jun 30, 2007 5:30 pm
by Benjamin
What does the second parameter of number_format do per the manual?
Posted: Sat Jun 30, 2007 5:32 pm
by toasty2

Thanks, sometimes the arguments list tells you more than the descriptions about them.