将日期转换为T Z格式 [英] convert date to T Z format

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

问题描述

我的日期格式是这样的

2013-05-07 18:56:57 (yyyy-MM-dd hh:mm:ss)

我希望输出如下.

2013-05-07T06:17:55.827Z

有没有比使用大功能简单的方法?

Is there a simple way than using big functions ?

推荐答案

这应该在Z(ulu)时区中给出正确的ISO8601日期/时间:

This should give the proper ISO8601 date/time in Z(ulu) timezone:

str_replace('+00:00', 'Z', gmdate('c'))

要进行日期转换:

str_replace('+00:00', 'Z', gmdate('c', strtotime('2013-05-07 18:56:57')))

拥有附加的.000(这是无用的恕我直言):

To have the additional .000 (which is useless imho):

str_replace('+00:00', '.000Z', gmdate('c', strtotime('2013-05-07 18:56:57')))

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

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