How to convert milliseconds to time in php: First create a PHP sample file; then use the substr function to intercept the first ten digits of the millisecond timestamp; and finally convert the time through the date method.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
Specific questions:
php How to convert milliseconds into time? PHP gets the specific Y-m-d H:i:s time through the millisecond timestamp?
php gets the specific Y-m-d H:i:s time through the millisecond timestamp?
For example, the millisecond timestamp is: The corresponding format of 1492396179000 is: 2017-04-17 10:29:39
Implementation method:
Use substr to intercept the first ten digits of the millisecond timestamp. Ah, for example:
date_default_timezone_set('PRC'); $time = 1492396179000; $time = substr($time,0,10); $date = date('Y-m-d H:i:s',$time); echo $date;
[Recommended learning: PHP video tutorial]
The above is the detailed content of How to convert time in milliseconds in php. For more information, please follow other related articles on the PHP Chinese website!