简体   繁体   English

如何在PHP上获取DateTime格式:2016-01-29T09:29:29.5033083 + 03:00

[英]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.phphttp://php.net/manual/en/function.mktime.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在PHP中获取输出日期格式为2016-05-03T01:38:54.003Z? - How to get the output date format as 2016-05-03T01:38:54.003Z in PHP? 在PHP中将2017-09-29T17:57:49到5:57格式 - Format 2017-09-29T17:57:49 to 5:57 in PHP 如何在PHP中使用类似``2019-07-20T09:20:33 + 00:00&#39;&#39;的格式获取Carbon时间 - How to get Carbon time with format like that '2019-07-20T09:20:33+00:00' in PHP php 2021-07-09T14:09:47.529751-04:00 什么样的数据时间格式以及如何处理 - What kind of data time format and how to process this in php 2021-07-09T14:09:47.529751-04:00 错误:带时区的时间戳类型的输入语法无效:“09/03/1943 01:00:00 MWT” - ERROR: invalid input syntax for type timestamp with time zone: "09/03/1943 01:00:00 MWT" new DateTime(&#39;2016-04-01 00:00:00&#39;)返回&#39;2016-04-01 12:00:00 - new DateTime('2016-04-01 00:00:00') returns '2016-04-01 12:00:00 我 mongodb 我的日期在 01-03-2016 00:12 格式化我如何使用日期查找数据 - i mongodb my date in 01-03-2016 00:12 formate how can i find data by using date 如何计算 01-01-2016 到 31-01-2016 的持续时间。 用 PHP 1 个月获得答案 - How to Calculate duration 01-01-2016 to 31-01-2016 . get answer 1 month in PHP 如何从2014-09-02T08:54:03Z创建DateTime对象 - How to Create DateTime object from 2014-09-02T08:54:03Z 如何创建像2013-09-21T18:56:19 + 00:00这样的PHP日期? - How to create a PHP date like 2013-09-21T18:56:19+00:00?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM