PHP获取毫秒时间戳的方法有哪些

PHP
1710
2024/2/21 17:32:26
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

  1. 使用microtime函数:
$time = microtime(true) * 1000;
echo $time;
  1. 使用DateTime类:
$dateTime = new DateTime();
$milliseconds = $dateTime->getTimestamp() * 1000 + round($dateTime->format('u') / 1000);
echo $milliseconds;
  1. 使用gmdate函数:
$milliseconds = gmdate('U') * 1000 + round(gmdate('u') / 1000);
echo $milliseconds;

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: php imagecreatefrompng怎样减少内存占用