0

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.

0

2 Answers 2

4

Use round to fix the decimal points

$time = microtime();
echo round($time, 2);
Sign up to request clarification or add additional context in comments.

1 Comment

There's also sprintf('%0.2f', $time) and the like. PHP has LOTS of options for formatting numbers.
2
$ms = microtime(true);
mysql_query($sql);
$ms = microtime(true) - $ms;
echo $ms.' secs'; //seconds
echo ($ms * 1000).' millisecs'; //millseconds

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.