This is answered by example #2 from the manual on microtime:
Example #2 Timing script execution in PHP 5
<?php
$time_start = microtime(true);
// Sleep for a while
usleep(100);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
?>
Combine this with this answer and you get:
$time_start = microtime(true);
// Do something here that takes time ...
$time_end = microtime(true);
$time = $time_end - $time_start;
$micro = sprintf("%06d", ($time - floor($time)) * 1000000);
$dateObj = new DateTime( date("Y-m-d H:i:s.$micro", $time) );
$interval = $dateObj->format("H:i:s.u");
If the time difference would be one minute, 23 seconds and 501293 micro seconds, then $difference will have this string value:
00:01:23.501293