GDATA Feed API - 在 PHP 中解析时间戳
我目前正在使用 YouTube 的 feed API 来获取有关 YouTube 频道上传的视频的信息。 Feed 示例类似于 http://gdata.youtube。 com/feeds/api/users/google/uploads?v=2
Feed 中的时间戳采用以下格式2011-04-27T20:54:42.000Z
。我如何将其转换为更具可读性的内容,例如 2011 年 4 月 27 日晚上 8:54:42
?
I'm currently using YouTube's feed API to get information about a YouTube channel's uploaded videos. An example feed would be something like http://gdata.youtube.com/feeds/api/users/google/uploads?v=2
Timestamps in the feed are in the format 2011-04-27T20:54:42.000Z
. How would I convert that to something more readable, like April 27th, 2011 at 8:54:42pm
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
DateTime::createFromFormat
从该格式创建一个新的 DateTime 对象,然后您可以使用该对象的format
方法以您想要的方式输出它。Use
DateTime::createFromFormat
to create a new DateTime object from that format, then you can output it however you want using the object'sformat
method.您可以使用 strtotime 的组合,它将字符串转换为 UNIX 时间戳,和 date,它将时间戳转换为人类可读的输出:
实例
You can use a combination of strtotime, which converts a string into a UNIX timestamp, and date, which converts a timestamp into human-readable output:
Live example