php日志显示毫秒时间

2020-12-03  本文已影响0人  西湖泛舟客

最近的工作中,需要显示日志的毫秒时间。

记录一下,写的方法。

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());

显示效果:

这是本地测试的效果,错误是因为有些参数,本地传不了

上一篇 下一篇

猜你喜欢

热点阅读