Andy82 Posted October 30, 2008 Share Posted October 30, 2008 Hey, I am learning PHP and am having a problem with using microtime. I am trying to make a page load timer and the tutorials I have found use microtime. The code I have come up with is: <?php error_reporting(0); $page_load_start = microtime(); //the include files are here.... $page_load_end = microtime(); $page_load_time = $page_load_end - $page_load_start; print("<!-- Time: " . $page_load_time . "-->"); ?> This produces a result that is about 10 digits long e.g. 1.230000000001 How would I make this number down to 1.23 seconds? I have looked at trim() and substr() but no luck. Thank you for any help Andy Link to comment https://forums.phpfreaks.com/topic/130800-solved-newbie-microtime-help/ Share on other sites More sharing options...
trq Posted October 30, 2008 Share Posted October 30, 2008 print("<!-- Time: " . number_format($page_load_time, 2) . "-->"); Link to comment https://forums.phpfreaks.com/topic/130800-solved-newbie-microtime-help/#findComment-678840 Share on other sites More sharing options...
Andy82 Posted October 30, 2008 Author Share Posted October 30, 2008 Thank you very much, I really appreciated it Link to comment https://forums.phpfreaks.com/topic/130800-solved-newbie-microtime-help/#findComment-678843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.