MathCurvesSurfacesWallpaper GroupsGallerySoftwarePOV-Ray
ProgramingLinuxPerl PythonHTMLCSSJavaScriptPHPJavaEmacsUnicode ♥
Web Hosting by 1&1

HTML5 “time” Tag

Xah Lee, ,

The “time” tag is used to represent date/time combination. Examples:

<footer>Published <time pubdate datetime="2011-07-03">07/03</time>.</footer>
I need this <time datetime="2011-07-03 12:28:57-07:00">now</time>!
Captain's log, date <time>2011-07-03 12:51:02-07:00</time>.

The text content between the tag must be in a exact datetime format, as used by the optional attribute “datetime”.

“datetime” Attribute

“datetime” attribute encodes the precise date or date/time. The format must be exact, and must include at least “yyyy-mm-dd”. (time info is optional) Examples:

… mom's birthday <time datetime="2011-07-03">July 3rd</time> …
… had piano lesson at <time datetime="2011-07-03 13:00">1 pm</time> …
… the bomb went off at <time datetime="2011-07-03 12:46:03-07:00">12:46:03 PST</time> …

The “datetime” attribute is optional. But if not present, then the “time” tag's content must use the same fomat used by “datetime” attribute. ⁖ yyyy-mm-dd hh:mm:ss-hh:mm.

Sample Correct Formats

The space between date and time can also be “T”. Example: 2011-07-03T12:58

Wrong Examplez

“pubdate” Attribute

“pubdate” boolean attribute can be included. If present, that means your time tag represent the time your article is published. Example:

<time pubdate>2011-07-03 13:05:28-07:00</time>
<time pubdate datetime="2011-07-03 13:05:28-07:00">July 03</time>

Note that “pubdate” does not take any values. It is wrong to say pubdate="…".

Back to HTML5 Tags.

blog comments powered by Disqus