note 119814 added to function.gmdate
| From: | genna87 at gmail dot com | Date: | Wed, 31 Aug 2016 11:09:09 +0000 |
| Subject: | note 119814 added to function.gmdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206429@lists.php.net to get a copy of this message | ||
A function to get the ISO 8601 timestamp in UTC with precision up to microseconds
function iso_8601_utc_time($precision = 0)
{
$time = gettimeofday();
if (is_int($precision) && $precision >= 0 && $precision <= 6) {
$total = (string) $time['sec'] . '.' . str_pad((string)
$time['usec'], 6, '0', STR_PAD_LEFT);
$total_rounded = bcadd($total, '0.' . str_repeat('0', $precision) .
'5', $precision);
@list($integer, $fraction) = explode('.', $total_rounded);
$format = $precision == 0
? "Y-m-d\TH:i:s\Z"
: "Y-m-d\TH:i:s,".$fraction."\Z";
return gmdate($format, $integer);
}
return false;
}
----
Server IP: 72.52.91.14
Probable Submitter: 188.9.206.157
----
Manual Page -- http://php.net/manual/en/function.gmdate.php
Edit -- https://master.php.net/note/edit/119814
Del: integrated -- https://master.php.net/note/delete/119814/integrated
Del: useless -- https://master.php.net/note/delete/119814/useless
Del: bad code -- https://master.php.net/note/delete/119814/bad+code
Del: spam -- https://master.php.net/note/delete/119814/spam
Del: non-english -- https://master.php.net/note/delete/119814/non-english
Del: in docs -- https://master.php.net/note/delete/119814/in+docs
Del: other reasons-- https://master.php.net/note/delete/119814
Reject -- https://master.php.net/note/reject/119814
Search -- https://master.php.net/manage/user-notes.php