In an ISO 8601 date, is the T character mandatory?

SCO picture SCO · Mar 2, 2012 · Viewed 11.5k times · Source

I'm wondering if the following date is ISO8601 compliant :

2012-03-02 14:57:05.456+0500

(for sure, 2012-03-02T14:57:05.456+0500 is compliant, but not that much human readable !) IOW, is the T between date and time mandatory ?

Answer

Keith Thompson picture Keith Thompson · Mar 2, 2012

It's required unless the "partners in information interchange" agree to omit it.

Quoting the ISO 8601 standard, section 4.3.2:

The character [T] shall be used as time designator to indicate the start of the representation of the time of day component in these expressions. [...]

NOTE By mutual agreement of the partners in information interchange, the character [T] may be omitted in applications where there is no risk of confusing a date and time of day representation with others defined in this International Standard.

Omitting it is fairly common, but leaving it in is advisable if the representation is meant to be machine-readable and you don't have a clear agreement that you can omit it.

UPDATE : Mark Amery's comment makes a good point, that permission to omit the [T] does not necessarily imply permission to replace it with a space. So this:

2012-03-02T14:57:05.456+0500

is clearly compliant, and this:

2012-03-0214:57:05.456+0500

is permitted if the partners agree to omit the [T], but this:

2012-03-02 14:57:05.456+0500

apparently is not (though it's much more readable than the version with the [T] simply omitted).

Personally, if ISO 8601 compliance were required, I'd include the [T], and if it weren't then I'd use a space (or a hyphen if it's going to be part of a file name). My guess, and it's nothing more than that, was that the intent was to allow the 'T' to be replaced by a space, but the standard doesn't say that.

See also RFC 3339 section 5.6, mentioned in Charles Burns's answer.