Hey how's it going?
I need some help understanding how I could go about doing this. Basically I am looking for a "Your page loaded in .01 seconds." type thing.
I am using this code from PHP.net:
<?php
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
// Sleep for a while
usleep(100);
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
?>
However, the answers I am getting are like (9.7990036010742E-005) Which you cannot say that to a user. I know my page loads pretty fast (my pages are rather small). But for a final project in my class I need to have it display the time it took to generate the page. That is fine, but having 9.7990036010742E-005 is too much, and 0 seconds is not enough. Because it's not even taking a whole second to do the page load.
Any help on this would be much appreciated!
Thanks,
Chad R. Smith