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);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

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