<time> element has had an off-again, on-again relationship with HTML5. Removed from the specification by WHATWG, it was quickly reinserted after an uprising from the web development community.
<time> is not just back, it’s improved and better than ever, with many of the element’s new attributes officially supported in an expanded specification.
<time> surrounds time and date content on your page, in almost any context: the only requirement is that the date must be anytime between 0 CE and the future, as the element cannot take negative values.
<time> allows the browser, search engines and other applications to understand the specific time and date that is referenced on a web page, rather than guessing.
The simplest example is a year date:
<p>The <time datetime="1816">year without a summer</time>.</p>
Or a month, for any year:
<p>Remember, remember <time datetime="11-05">the fifth of November</time>, Guy Fawkes Day.</p>
Month and year or full date:
<p>Construction of the Berlin Wall began in <time datetime=1961-08>August 1961</time>. It fell on <time datetime="1989-11-09">9 November, 1989.</time></p>
Obviously we can also talk about dates in the future. Full dates should include a time, in 24-hour (military) format, separated from the date by a
T character or a space:
<p>The working group’s presentations have been rescheduled for<time datetime="2012-03-07T15:00">3pm next Wednesday</time></p>
(Note that the W3C validator currently allows the full date without time information; it may not yet recognize the year-only and month-year combinations shown above).
For exact moments in time, we can also supply seconds:
<p>I’ll see everyone at <time datetime="2012-02-21 20:00:00">the party next Tuesday</time></p>
That’s a good start, but remember that all web pages are international: a browser looking at the
datetime value above has no idea which side of the international date line the page is talking about. While not having this information is allowed by the W3C validator, you should always add time zone details by specifying the offset between the location of the event and UTC (Coordinated Universal Time) traditionally known as Greenwich Mean Time. For example, Calgary is in the Mountain Time Zone, seven hours behind London. With that information, the HTML code would become:
<p>I’ll see everyone <time datetime="2012-02-21T20:00:00-07:00">next Tuesday</time></p>
Alternatively, using just the time:
<p>You have a meeting at <time datetime="09:00-07">9am</time></p>