这个日期时间字符串是什么格式:2001-12-17T09:30:47-05:00 [复制]

This question already has an answer here:

I need to generate a MessageTime for a xml based api. In the example request file, they are using the following:

<MessageTime>2001-12-17T09:30:47-05:00</MessageTime>

What is the format of this datetime string? I want to generate it using date() method or DateTime class.

This is what I tried so far: I am in the UK, so i am using the offset 00:00

var_dump(date('Y-m-d\TH:i:s').'-00:00')
// Output: 2014-05-26T20:11:45-00:00

Is this correct?

</div>

ISO 8601 date (added in PHP 5):

date('c');

Or using a constant:

date(DateTime::ISO8601);

You can also utilize O for the "difference to Greenwich time (GMT) in hours":

date('Y-m-d\TH:i:sO');