HTML and CSS Reference
The <time> element
<time> is a new element for unambiguously encoding dates and
times for machines, while still displaying them in a human-read-
able way. The uses of this in web pages aren't hard to imagine:
a browser could offer to add future events to a user's calendar;
content aggregators could produce visual timelines of events;
a Thai-localised browser could offer to transform dates into Thai
Buddhist era dates, which are numerically 543 years greater
than their corresponding Western-style years.
The spec says “The time element represents either a time on a
24-hour clock, or a precise date in the proleptic Gregorian cal-
endar, optionally with a time and a time-zone offset.”
The machine-readable part of the <time> element is usually
encapsulated in the element's datetime attribute. The content
inside the element is what gets presented to end users.
<time datetime=2009-11-13>13 November 2009</time>
<time datetime=2009-11-13>13<sup>th</sup> November last
<time datetime=2010-11-13>Bruce's 21st birthday</time>
<time datetime=2010-11-13T020:00Z>8PM on my birthday</time>
<time datetime=20:00>8 PM</time>
If you're happy to have the machine-readable format visible to
the end user as well, you don't need to use a separate datetime
attribute. User agents should then simply pick the content of the
element and interpret it:
Machine-readable dates and times
To b e m a c h i in e - r e a d a b l e , d a t e s m u s t b e i in t h e f To r m a t Y Y Y Y- M M - D D a in d m a y a l s To i in c l u d e a t i m e , p r e fi xe d
with “T” to separate the date and time, in the format HH:MM. Optionally you can append seconds (sepa-
rated from the minutes with a colon). Fractions of a second are allowed after a full stop mark.
As you've seen above, you can give a time on the 24-hour clock with no date information.
If you're giving time and date together, you need to show the time zone: that's either “Z” for Coordinated
Universal Time (UTC), or an offset from UTC in hours and minutes, prefi xed with a plus or minus.
Putting that all together: “1979-10-14T12:00:00.001-04:00” represents one millisecond after noon on
October 14th, 1979, in Eastern Standard Time during daylight saving time (UTC—4 hours).