美文网首页
php日志显示毫秒时间

php日志显示毫秒时间

作者: 西湖泛舟客 | 来源:发表于2020-12-03 19:47 被阅读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());

显示效果:

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

相关文章

网友评论

      本文标题:php日志显示毫秒时间

      本文链接:https://www.haomeiwen.com/subject/vfcvwktx.html