Como subtrair microtime e exibir data com milissegundos em php?
Como subtrair microtime e exibir data com milissegundos em php?
Por exemplo: eu configurei a data e a hora de término
$endtime = 2012-02-21 10:29:59;
ntão, eu tenho a data atual ou a data de início convertida de 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
Agora quero subtrair: $ finaldate = $ endtime - $ starttime;
Quero que minha saída seja assim: 00: 00: 02.452