需要精確計算程序執行時間時,可以使用毫秒單位來進行計算:
step1
//獲取當前時間毫秒
function msectime()
{
list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
return $msectime;
}
step2
$time = msectime();
$ts = date('YmdHis').substr($time, -3);