Question

I have been looking around the web for this but cannot really find a good answer. I have a small site search and I want to display the time it took the mysql query to execute (similar to Google). I've been trying to use microtime() but I get huge strings like 1.342524564267782e25... I just want a simple digit with two decimals following (0.15). Thanks in advanced.

Was it helpful?

Solution

Use round to fix the decimal points

$time = microtime();
echo round($time, 2);

OTHER TIPS

$ms = microtime(true);
mysql_query($sql);
$ms = microtime(true) - $ms;
echo $ms.' secs'; //seconds
echo ($ms * 1000).' millisecs'; //millseconds
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top