Last active
February 8, 2018 17:46
-
-
Save garvin/9da96f6ef1e82a5399d0339091f7b8fe to your computer and use it in GitHub Desktop.
Function to generate a timestamp (in # of milliseconds)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate a timestamp (in # of milliseconds) | |
* | |
* @return string | |
*/ | |
function millitime() { | |
$microtime = microtime(); | |
$comps = explode(' ', $microtime); | |
// Note: Using a string here to prevent loss of precision | |
// in case of "overflow" (PHP converts it to a double) | |
return sprintf('%d%03d', $comps[1], $comps[0] * 1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment