AZForums: Creating a PHP Script Timer - AZForums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Creating a PHP Script Timer <?php>

#1 User is offline   Oosband Icon

  • DnB Oos
  • PipPipPipPipPipPipPipPipPipPip
  • View blog
Group:
+ Legendary
Posts:
5,527
Joined:
30-August 05
Location:
UK

Posted 09 April 2006 - 04:54 PM

This timer is easy to implement and determines the time taken for a php script to execute correct to a microsecond.

Insert this code at the top of the page:
<?php 
	  $mtime = microtime(); 
	  $mtime = explode(' ', $mtime); 
	  $mtime = $mtime[1] + $mtime[0]; 
	  $starttime = $mtime; 
?>


Then at the bottom of the page add the following:
<?php 
	  $mtime = microtime(); 
	  $mtime = explode(" ", $mtime); 
	  $mtime = $mtime[1] + $mtime[0]; 
	  $endtime = $mtime; 
	  $totaltime = ($endtime - $starttime); 
	  echo 'This page was created in ' .$totaltime. ' seconds.'; 
?>


PHP's microtime() function returns the current Unix timestamp with microseconds.
0

#2 User is offline   devcline Icon

  • AZ Beginner
  • PipPip
  • View blog
Group:
Members
Posts:
21
Joined:
11-November 08

Posted 11 November 2008 - 02:58 PM

cool :) There is any way to show a small micro time. Because the format 0,013962984085083 seconds is too long . Nice math !
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users