如何在毫秒中减去microtime和显示日期?如何在毫秒中减去microtime和显示日期以毫秒?
例如:我已经设定结束日期和时间
$endtime = 2012-02-21 10:29:59;
然后,我有当前日期或转换来自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
现在我想减去: $ finaldate = $ endtime - $ starttime;
我希望我的输出是这样的:00:00:02.452