Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomasmuller/276789 to your computer and use it in GitHub Desktop.
Save tomasmuller/276789 to your computer and use it in GitHub Desktop.
function currentTimeMillis() {
list($usec, $sec) = explode(" ", microtime());
return round(((float)$usec + (float)$sec) * 1000);
}
@NeerajBro
Copy link

$times = gettimeofday();
$seconds = strval($times["sec"]);
$milliseconds = strval(floor($times["usec"]/1000));
$missingleadingzeros = 3-strlen($milliseconds);
if($missingleadingzeros >0){
for($i = 0; $i < $missingleadingzeros; $i++){
$milliseconds = '0'.$milliseconds;
}
}
return intval($seconds.$milliseconds);

thanks to make my code more shorter :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment