// microtime(true) returns the unix timestamp plus milliseconds as a float $starttime = microtime(true); /* do stuff here */ $endtime = microtime(true); $timediff = $endtime - $starttime;