How to subtract microtime and display date with milliseconds in php ?
For example: I have set end date and time
$endtime = 2012-02-21 10:29:59;
then I have current date or start date with converted from microtime
$starttime = 2012-02-21 10:27:59.452;
function getTimestamp()
{
$microtime = floatval(substr((string)microtime(), 1, 8));
$rounded = round($microtime, 3);
return date("Y-m-d H:i:s") . substr((string)$rounded, 1, strlen($rounded));
}
echo getTimestamp(); //sample output 2012-02-21 10:27:59.452
Now I want to subtract: $finaldate = $endtime - $starttime;
I want my output to be like this: 00:00:02.452