如何将 YouTube 返回的日期解析为时间戳?
YouTube 返回更新日期
和提交日期
,如下所示:2010-08-22T04:46:18.000Z
是否有 PHP 函数,或者解析这个的日期掩码?
YouTube returns the Updated date
and Submitted on
date as follows: 2010-08-22T04:46:18.000Z
Is there a PHP function, or a date mask that parses this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这使用
DateTime
类。它能够识别时区和小数秒。要显示日期,请使用格式
方法:要将日期转换为本地时区,请使用
setTimezone
方法:This uses the
DateTime
class. It is timezone and fractional seconds aware. To display the date use theformat
method:To convert the date to local timezone use the
setTimezone
method:听起来 strtotime 就是您要寻找的。
编辑:如果这不起作用,请查看日期和时间类 - 有一些方法可以解析指定格式的日期(像这样 - 不直接返回时间戳,但是如果您从中构造一个 DateTime,则可以使用它的 getTimestamp-方法)
sounds like strtotime is what you're looking for.
EDIT: if this doesn't work, take a look at the Date and Time classes - there are methods for parsing dates in specified formats (like this - doesn't return a timestamp directly, but if you construct a DateTime from this, you can use it's getTimestamp-method)
试试这个:
末尾的“z”似乎是 strtotime 的问题。
Try this:
The "z" at the end seems to be the problem for strtotime.