- 使用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;