Javascript: console.log time



我想以粗略的形式输出php代码中两个事件之间的毫秒数。

为了做到这一点,我希望能够用最少的代码显示这样的东西:

23:01:30:220//表示23小时1分30秒220毫秒

如何将这样的时间戳添加到控制台日志函数中?

console.log(event);

我看到了跨越5行的代码,但我希望我能做一些类似的事情

console.log(Time + " " + event);

有这么简单的功能吗?

谢谢。

在PHP中没有办法使用consloe.log,但您可以简单地尝试下面的代码:

$starttime = microtime(true); // Top of page
// Code
$endtime = microtime(true); // Bottom of page
printf("Page loaded in %f seconds", $endtime - $starttime );

最新更新