Skip to content

Instantly share code, notes, and snippets.

@alash3al
Created August 20, 2015 19:30
Show Gist options
  • Save alash3al/c71983b4b324f84795b2 to your computer and use it in GitHub Desktop.
Save alash3al/c71983b4b324f84795b2 to your computer and use it in GitHub Desktop.
milliseconds - return current Unix timestamp with milliseconds for php just like javascript's Date.now()
<?php
/*
* Return current Unix timestamp with milliseconds
*
* @author Mohammed Al Ashaal <github/alash3al, fb/alash3al, tw/m7medalash3al>
* @return float "due to INT limitaions"
*/
public function milliseconds()
{
list($a, $b) = explode(' ', microtime());
return floatval(intval($b) . "" . intval($a * 1000));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment