Home > Article > Backend Development > How to get the current timestamp in php
php gets the number of digits of the current timestamp
php gets the 10 digits of the current timestamp.
Example:
<?php //unix时间戳 $time = time(); //转成时间格式 $dadte = date('Y-m-d H:i:s',$time); echo $time; echo "<br>"; echo $dadte; ?>
Effect:
1572399129 2019-10-30 01:32:09
java, the timestamp of javascript is 13 digits, how to implement php to obtain the 13-digit timestampHere, let’s look at the code
<?php function getUnixTimestamp () { list($s1, $s2) = explode(' ', microtime()); return (float)sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000); } echo time(); echo "<br>"; echo getUnixTimestamp();
Effect:
1572399322 1572399322925
For more PHP-related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to get the current timestamp in php. For more information, please follow other related articles on the PHP Chinese website!