April 7, 2012

Displaying MySQL execution time in PHP

Question by 4WebDev

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.

Answer by Starx

Use round to fix the decimal points

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

Please fill the form - I will response as fast as I can!