i got this from an article on phpbuilder...
as early as possible in the code, put the following
list($usec, $sec) = explode(" ",microtime());
$timestart = ((float)$usec + (float)$sec);
this calculates the time, in seconds since the unix epoch, that the page started.
then, put this at or near the end of the code
list($usec, $sec) = explode(" ",microtime());
$timeend = ((float)$usec + (float)$sec);
$timetaken = $timeend - $timestart;
$timetaken = number_format($timetaken, 4, '.', '');
this calculates the time the page ends, then $timeend - $timestart is the time taken, which is then formatted to 0.0000
as most php pages will execute in well under a second, you probably wont want to display it just in seconds, which is why i use four decimal places - most of my pages complete in hundredths of a second.