Posted By

okhy on 11/21/11


Tagged

get microtime milliseconds


Versions (?)

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);
  4.  
  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.