最近的工作中,需要显示日志的毫秒时间。
记录一下,写的方法。
function udate($format, $timestamp=null) {
$utimestamp = microtime(true);
t i m e s t a m p = f l o o r ( timestamp = floor(timestamp=floor(utimestamp);
m i l l i s e c o n d s = r o u n d ( ( milliseconds = round((milliseconds=round((utimestamp - $timestamp) * 1000);
return date(preg_replace(’(?<!\\\\)u’, $milliseconds, $format), $timestamp);
}
echo udate(‘Y-m-d H:i:s.u’, time());
显示效果:
这是本地测试的效果,错误是因为有些参数,本地传不了