note 110058 added to datetime.gettimestamp
| From: | junk at gieson dot com | Date: | Sat, 15 Sep 2012 08:02:13 +0000 |
| Subject: | note 110058 added to datetime.gettimestamp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190780@lists.php.net to get a copy of this message | ||
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;
}
}
----
Server IP: 69.147.83.199
Probable Submitter: 68.57.9.168
----
Manual Page -- http://www.php.net/manual/en/datetime.gettimestamp.php
Edit -- https://master.php.net/note/edit/110058
Del: integrated -- https://master.php.net/note/delete/110058/integrated
Del: useless -- https://master.php.net/note/delete/110058/useless
Del: bad code -- https://master.php.net/note/delete/110058/bad+code
Del: spam -- https://master.php.net/note/delete/110058/spam
Del: non-english -- https://master.php.net/note/delete/110058/non-english
Del: in docs -- https://master.php.net/note/delete/110058/in+docs
Del: other reasons-- https://master.php.net/note/delete/110058
Reject -- https://master.php.net/note/reject/110058
Search -- https://master.php.net/manage/user-notes.php