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

DateStandardsDatetime FormatIso

Date Problem Overview


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 ?

Date Solutions


Solution 1 - Date

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.

Solution 2 - Date

That date is not ISO-8601 compliant as Keith Thompson indicated, but it is compliant with RFC 3339, a profile of ISO 8601. Sort of. See NOTE at the bottom of the following text from RFC 3339:

date-time       = full-date "T" full-time

  NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this
  syntax may alternatively be lower case "t" or "z" respectively.

  This date/time format may be used in some environments or contexts
  that distinguish between the upper- and lower-case letters 'A'-'Z'
  and 'a'-'z' (e.g. XML).  Specifications that use this format in
  such environments MAY further limit the date/time syntax so that
  the letters 'T' and 'Z' used in the date/time syntax must always
  be upper case.  Applications that generate this format SHOULD use
  upper case letters.

  NOTE: ISO 8601 defines date and time separated by "T".
  Applications using this syntax may choose, for the sake of
  readability, to specify a full-date and full-time separated by
  (say) a space character.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSCOView Question on Stackoverflow
Solution 1 - DateKeith ThompsonView Answer on Stackoverflow
Solution 2 - DateCharles BurnsView Answer on Stackoverflow