PHP Milliseconds Timestamp: 3 Methods
- Utilize the microtime function:
$time = microtime(true) * 1000;
echo $time;
- Utilizing the DateTime class:
$dateTime = new DateTime();
$milliseconds = $dateTime->getTimestamp() * 1000 + round($dateTime->format('u') / 1000);
echo $milliseconds;
- Utilize the gmdate function:
$milliseconds = gmdate('U') * 1000 + round(gmdate('u') / 1000);
echo $milliseconds;