[英]How get DateTime Format on PHP: 2016-01-29T09:29:29.5033083+03:00
Who can say that over time, the date format is used here? 谁能说,随着时间的流逝,这里使用的是日期格式?
<Date>2016-01-29T09:29:29.5033083+03:00</Date>
I tried to do it on php$time = microtime(); 我试图在php $ time = microtime();上做
list($usec, $sec) = explode(" ", $time);
$datetime = new DateTime();
$datetime->setTimestamp($time);
$usec = $usec * 1000000;
echo date('Y-m-d\TH:i:s.'.$usec.'P') . "<hr>";
Result: 结果:
2016-05-19T12:52:04.415507+05:00
But the number of characters is not the same: 但是字符数不一样:
.5033083
.415507
How do I get this format to php? 如何将这种格式转换为php?
<Date>2016-01-29T09:29:29.5033083+03:00</Date>
This may be help you 这可能对您有帮助
date_default_timezone_set('UTC');
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
//prints something like: 2000-07-01T00:00:00+00:00
helping links are http://php.net/manual/en/function.date.php and http://php.net/manual/en/function.mktime.php 帮助链接为http://php.net/manual/en/function.date.php和http://php.net/manual/en/function.mktime.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.