2013-04-09T10:00:00Z的PHP格式 [英] Format of 2013-04-09T10:00:00Z in php

查看:120
本文介绍了2013-04-09T10:00:00Z的PHP格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找date()格式,该格式可以给我这样的日期:

I'm looking for the date() format that will give me a date like this:

2013-04-09T10:00:00Z

有没有比仅使用'Y-m-d ...'格式简单的东西了?

Is there something simpler than just using the format 'Y-m-d ...'?

推荐答案

gmdate()(用于UTC时间)一起使用的日期格式'c'(ISO 8601)非常接近:

The date format 'c' (ISO 8601) used with gmdate() (for UTC time) comes very close:

2013-04-09T10:00:00+00:00

您只需要通过将尾随的+00:00替换为Z(对于Zulu)进行修改即可:

You just need to modify it by replacing the trailing +00:00 with Z (for Zulu):

echo substr_replace(gmdate('c'), 'Z', -6);

替代方法很简单:

echo gmdate('Y-m-d\TH:i:s\Z');

这篇关于2013-04-09T10:00:00Z的PHP格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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