PHP DateTime :: createFromFormat不解析ISO 8601日期时间 [英] PHP DateTime::createFromFormat doesn't parse ISO 8601 date time

查看:130
本文介绍了PHP DateTime :: createFromFormat不解析ISO 8601日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码说出一百万字:

php > echo strtotime("2010-12-07T23:00:00.000Z");
1291762800
echo date('c', 1291762800);
2010-12-08T00:00:00+01:00
php > var_dump(DateTime::createFromFormat('c', "2010-12-07T23:00:00.000Z"));
bool(false)
php > var_dump(DateTime::createFromFormat(DateTime::ISO8601, "2010-12-07T23:00:00.000Z"));
bool(false)

任何想法发生了什么? Btw,是的,新的DateTime(2010-12-07T23:00:00.000Z)可以正常工作。

Any idea what's going on?

但我更喜欢知道我得到什么输入。

Btw, yes, new DateTime("2010-12-07T23:00:00.000Z") works fine. But I prefer to know what input I am getting.

推荐答案

嗯,这是DateTime中的一个错误:)

Well, it's a bug in DateTime :)

a href =https://bugs.php.net/bug.php?id=51950 =noreferrer> https://bugs.php.net/bug.php?id=51950

https://bugs.php.net/bug.php?id=51950

显然他们只希望你使用 strtotime new DateTime 。令人失望:(

Apparently they only want you to use strtotime or new DateTime. Disappointing :(

这篇关于PHP DateTime :: createFromFormat不解析ISO 8601日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆