Reputation: 12315
What is the correct format for a html5 <time datetime="" />
attribute? Do days come before month or vice versa:
<time datetime="yyyy-dd-mm"></time>
or
<time datetime="yyyy-mm-dd"></time>
where
mm = Month (ie 01)
dd = Day (ie 20)
Upvotes: 3
Views: 672
Reputation: 1503200
It's yyyy-mm-dd
, in order to comply with ISO-8601 and general sanity.
From the W3C proposed recommendation:
Note: While the formats described here are intended to be subsets of the corresponding ISO8601 formats, this specification defines parsing rules in much more detail than ISO8601. Implementors are therefore encouraged to carefully examine any date parsing libraries before using them to implement the parsing rules described below; ISO8601 libraries might not parse dates and times in exactly the same manner. [ISO8601]
That's the simplest indication I could find in the recommendation, although there's also the "dates" section which indicates that a date is a valid-month-string followed by a -
and then a day, and valid-month-string is defined as:
A string is a valid month string representing a year year and month month if it consists of the following components in the given order:
- Four or more ASCII digits, representing year, where year > 0
- A "-" (U+002D) character
- Two ASCII digits, representing the month month, in the range 1 ≤ month ≤ 12
Upvotes: 5