PHP获取毫秒时间戳的方法有哪些
lewis
2016-11-27
18次阅读
- 使用microtime函数:
$time = microtime(true) * 1000;
echo $time;
- 使用DateTime类:
$dateTime = new DateTime();
$milliseconds = $dateTime->getTimestamp() * 1000 + round($dateTime->format('u') / 1000);
echo $milliseconds;
- 使用gmdate函数:
$milliseconds = gmdate('U') * 1000 + round(gmdate('u') / 1000);
echo $milliseconds;

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。