Home > Backend Development > PHP Problem > How to convert time in milliseconds in php

How to convert time in milliseconds in php

藏色散人
Release: 2023-03-10 13:38:01
Original
4121 people have browsed it

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.

How to convert time in milliseconds in php

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;
Copy after login

[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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template