The <time> element has had an off-again, on-again relationship with HTML5. Removed from the specification several months ago 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 by the W3C.
<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>
(A nice way of calculating time offsets from UTC for different cities around the world is at timeanddate.com)
pubdate
pubdate is now supported by the W3C. Adding the pubdate attribute to <time> indicates the publication date of the first appropriate ancestor element . For example:
- <article>
- <time datetime="2012-02-18">Posted 18 February</time>
- </article>
…would indicate that the article was published on 18 February, 2012. A time with pubdate attribute directly in the <body> would indicate that the page was made on that date and time.
Ranges
Time now has the ability to describe time ranges and durations with the P prefix:
- <p>Bake the soufflé for <time datetime="P25M">25 minutes</time></p>
You can specify durations of weeks (W), days (D), minutes (M) and seconds (S). These units may be separated by spaces:
- <p>Wait <time datetime="P27D 7H 43M 11.5S">one lunar month</time>
- before testing for lycanthropy
Haha, that is actually incredibly clever.
![Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy] Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]](http://ecx.images-amazon.com/images/I/5192I1rtYnL._SL160_.jpg)

