PHP elapsed time

Find elapsed time in php using microtime.

<?php
$s = microtime(true);
sleep(1); // 1 seconds
$e = microtime(true);
$timediff = $e - $s;
echo 'Elapsed time (seconds): ' . sprintf('%0.2f', $timediff) . "\n";
?>
Elapsed time (seconds): 1.00
Env: PHP 5.5.9 (Linux)

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments