在PHP中,大多数的时间格式都是以UNIX时间戳来表示的,而UNIX时间戳是心秒为最小的计量时间的单位。这对于某些应用程序来说不够准确,所以可以调用microtime()返回当前UNIX时间戳和微秒数mixed microtime ([ bool $get_as_float ] )
如果给出了 get_as_float 参数并且其值等价于 TRUE,microtime() 将返回一个浮点数<?php
echo microtime() ."
";//0.72119500 1488282853
echo microtime(true) ;//1488282853.7212
?>
microtime()函数常用于性能分析<?php
date_default_timezone_set("PRC");
$start = microtime(true);
for($i=0; $i<100000; $i++);
$end = microtime(true);
echo $end-$start;//0.0067892074584961
?>