[英]Php Datetime convert to RFC 3339 string date to datetime type
I need a datetime as RFC3339
its for an api request from their documentation 我需要一个日期时间作为
RFC3339
用于其文档中的api请求
parameter type:datetime 参数类型:日期时间
format : RFC3339 格式:RFC3339
example: 1970-01-01T00:00:00Z
例如:
1970-01-01T00:00:00Z
Here is my code for convert datetime to RFC3339 这是我的将日期时间转换为RFC3339的代码
$datetime= date("c", strtotime("2014-03-10 05:40:00"));
it gives 2014-03-10T05:40:00+01:00
,but i will get error message from the api it says wrong date parameter 它给出了
2014-03-10T05:40:00+01:00
,但是我会从api收到错误消息,提示日期参数错误
var_dump($datetime)
gives type as string
but i need the type as datetime
so how can i convert RFC339 string date to datetime? var_dump($datetime)
将类型指定为string
但是我需要将类型指定为datetime
那么如何将RFC339字符串日期转换为datetime?
Php has predefined constants for most formats. Php具有大多数格式的预定义常数 。 You can simply use
您可以简单地使用
date(DATE_RFC3339);
or 要么
date(DATE_ATOM);
date('c')
is for a different format ISO 8601. date('c')
用于其他格式的ISO 8601。
Also, there is no "datetime" type in php. 另外,php中没有“ datetime”类型。 It's always going to return a string.
它总是要返回一个字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.