2014-07-07 07:45
浏览 144

PHP date()返回格式yyyy-mm-ddThh:mm:ss.uZ

I have checked out the following question/responses: How do I get the format of “yyyy-MM-ddTHH:mm:ss.fffZ” in php? The responses include links to Microsoft documentation to format dates but these do not work in PHP.

The the top answer suggest

date('Y-m-dTH:i:s.uZ') //for the current time

This outputs 2013-03-22EDT12:56:35.000000-1440016


I am working with an API which requires a timestamp in the format above. The API is based in the UK (GMT) and my server is in Australia (AEST).

The example given in the API documentation ask for the date to be in this format:


The closest I can get to this is date('c') which outputs:

2014-07-03T16:41:59+10:00//Notice the Z is replaced with a time diff in hours

I believe the 'Z' refers to a Zone but it is not mentioned in the PHP documentation.

Unfortunatly when I post this format, the API is reading the time and taking 10 hours off. I get an error saying that the date cannot be in the past (as it is checking against the local time in Melbourne, but seeing a time 10 hours earlier).

I have tried trimming the timestamp to remove the +1000 which the API accepts, but the record is showing as created as 10 hours earlier.

I need to match the timestamp required but I cannot find any way to replicate the above output, in PHP for Melbourne, Australia. Any assistance is much appreciated.

First question on SO so please let me know how I have gone

图片转代码服务由CSDN问答提供 功能建议

我检查了以下问题/回答: 如何获得”yyyy-MM-ddTHH:mm:ss“的格式。 fffZ“在PHP中? 响应中包含指向格式化日期的Microsoft文档的链接,但这些链接在PHP中不起作用。



输出 2013-03-22EDT12:56:35.000000-1440016


我正在使用 API需要上述格式的时间戳。 该API基于英国(GMT),我的服务器位于澳大利亚(AEST)。



我能得到的最接近的是日期('c' )输出:

2014-07-03T16:41:59 + 10:00 //注意Z用几小时的时差来代替


不幸的是,当我发布这种格式时,API正在读取时间并花费10个小时。 我得到一个错误,说日期不能过去(因为它是根据墨尔本当地时间检查,但是提前10小时查看)。

我试过修剪 删除API接受的+1000的时间戳,但记录显示为10小时前创建的。

我需要匹配所需的时间戳,但我找不到任何方法来复制 以上输出,用于澳大利亚墨尔本的PHP。 非常感谢任何帮助。


  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题