note 110058 deleted from datetime.gettimestamp by googleguy
| From: | googleguy@php.net | Date: | Sat, 15 Sep 2012 16:18:21 +0000 |
| Subject: | note 110058 deleted from datetime.gettimestamp by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190786@lists.php.net to get a copy of this message | ||
Note Submitter: junk at gieson dot com
----
On some versions of PHP, the timestamp with milliseconds is too large to display as a string. So use
the sprintf function to get the string value:
function getTimestamp2($asString=false){
$seconds = microtime(true); // false = int, true = float
$stamp = round($seconds * 1000);
if($asString == true){
return sprintf('%.0f', $stamp);
} else {
return $stamp;
}
}