Skip to content
PHP Logo

How can a microtimestamp be converted into a normal timestamp in PHP?

To convert a microtimestamp (which is a timestamp with microseconds) into a normal timestamp in PHP, you can divide the microtimestamp by 1,000 to get the seconds part and then use the date() function to format it into a readable date format.

php
$microtimestamp = 1625133423123456;
$timestamp = floor($microtimestamp / 1000000);
$normal_timestamp = date("Y-m-d H:i:s", $timestamp);
echo $normal_timestamp;