Mega Code Archive

 
Categories / Php / Date Time
 

You can always see the Loading time... in many web sites

Well this is a simple way on how to do it: <?php // Get Current Time $mtime = microtime(); // Split Seconds and Microseconds $mtime = explode (" ", $mtime); // Create a single value for start time $mtime = $mtime[1] + $mtime[0]; // Write Start Time Into A Variable $tstart = $mtime; // Get current time (Like above) to get end time $mtime = microtime(); $mtime = explode (" ", $mtime); $mtime = $mtime[1] + $mtime[0]; // Store end time in a variable $tend = $mtime; // Calculate Difference $totaltime = ($tend - $tstart); // Output the result printf ("This page was generated in %f seconds.", $totaltime); ?>