PHP解析日期为ISO格式 [英] PHP Parse date in ISO format

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

问题描述

我目前正在使用ConstantContact,它返回XML格式的更新字段,如下所示:

I'm currently using ConstantContact which returns XML with updated field in format like this:

2013-02-13T08:35:34.195Z

我假设这是 date('c')格式。如何解析这个格式? strtotime 没有返回正确的值。

I'm assuming this is date('c') format. How to parse this format? strtotime isn't returning correct value.

推荐答案

你可能想看看<一个href =http://www.php.net/manual/en/datetime.createfromformat.php> DateTime :: createFromFormat()函数。

$datetime = DateTime::createFromFormat('Y-m-d\TH:i:s+', '2013-02-13T08:35:34.195Z');

这个问题是你将要松开毫秒。

The problem with that is you're going to loose the milliseconds.

格式字符串中的 + 只是简单地告诉这个函数忽略其余的字符串,而不是创建一个错误。

The + sign in the format string simply tells this function to ignore the rest of the string instead of creating an error.

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

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