Example code of how php generates millisecond timestamp

黄舟
Release: 2023-03-16 10:38:01
Original
1352 people have browsed it

The php time function time() generates the seconds of the current time, but in some cases we need to get the current server time and the milliseconds of GMT (Greenwich Mean Time) January 1970 0:00:00, with The same as the currentTimeMilis() function in Java.

Example:

 public function getCurrentMilis() {     $mill_time = microtime();         $timeInfo = explode(' ', $mill_time);         $milis_time = sprintf('%d%03d',$timeInfo[1],$timeInfo[0] * 1000);     return $time;   }
Copy after login


The above is the detailed content of Example code of how php generates millisecond timestamp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!