How to get Page Loading Time using PHP

Using microtime() PHP function you will know exactly how much time is needed for your PHP code to be executed. Follow the steps below to put the PHP code on your web page. You may also like How to Interval Timer Countdown using setTimeout().

PHP and HTML Code

$start_time = microtime(TRUE);
        Your html Code <br />

$end_time = microtime(TRUE);
$time_taken = ($end_time - $start_time) * 1000;
$time_taken = round($time_taken, 5);
echo 'Page generated in ' . $time_taken . ' seconds.';

Leave a Reply

Your email address will not be published. Required fields are marked *