Home  >  Article  >  Backend Development  >  How to create millisecond timestamp in PHP

How to create millisecond timestamp in PHP

一个新手
一个新手Original
2017-09-19 09:10:371543browse

PHP's time() function 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. I think the following function is the most suitable, so I recorded it.

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

The above is the detailed content of How to create millisecond timestamp in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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