Posted By

okhy on 11/21/11


get microtime milliseconds

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


PHP Microtime

 / Published in: PHP

This function will give you something like milliseconds in Javascript, like: new Date().getTime();

  1. function getMicrotime(){
  2. $microtime = microtime();
  3. $comps = explode(' ', $microtime);
  5. // Note: Using a string here to prevent loss of precision
  6. // in case of "overflow" (PHP converts it to a double)
  7. return sprintf('%d%03d', $comps[1], $comps[0] * 1000);
  8. }

Report this snippet  

You need to login to post a comment.