Time tag in HTML5


HTML 5 is the latest version of HTML that introduces several new tags. The <time> tag is also a new tag in HTML5. The time tag defines date, time or date and time both by using this tag in the HTML document.
The syntax of <time> tag is as:
<time datetime="value"> Text Here</time>
 August 30, 2011 is the latest in the year.
Date and time:
Time only:


HTML tags can contain one or more attributes. Attributes are added to a tag to provide the browser with more information about how the tag should appear or behave. Attributes consist of a name and a value separated by an equals (=) sign, with the value surrounded by double-quotes.
There are 3 kinds of attributes that you can add to your HTML tags: Element-specific, global, and event handler content attributes. The attributes that you can add to this tag are listed below.

Element-Specific Attributes

The following table shows the attributes that are specific to this tag/element.
Attributes Introduced by HTML5
Attributes Description             
Pubdate Specifies that date andtime in the time element is the publication date and time of the document or the nearest ancestor article element.
datetime The datetime attributeSpecifies that the date or time for the time element. This attribute isused if no date or time is specified in the element's content.

Global Attributes

The following attributes are standard across all HTML 5 tags.
HTML5Global Attributes
accesskey draggable style
class hidden tabindex
dir spellcheck  
contenteditable id title
contextmenu lang  

Event Handler Content Attributes

Here are the standard HTML 5 event handler content attributes.
onabort onerror* onmousewheel
onblur* onfocus* onpause
oncanplay onformchange onplay
oncanplaythrough onforminput onplaying
onchange oninput onprogress
onclick oninvalid onratechange
oncontextmenu onkeydown onreadystatechange
ondblclick onkeypress onscroll
ondrag onkeyup onseeked
ondragend onload* onseeking
ondragenter onloadeddata onselect
ondragleave onloadedmetadata onshow
ondragover onloadstart onstalled
ondragstart onmousedown onsubmit
ondrop onmousemove onsuspend
ondurationchange onmouseout ontimeupdate
onemptied onmouseover onvolumechange
onended onmouseup onwaiting
For Example

Pubdate attribute

The pub date attribute specifies that the time element specifies the publication date of the nearest (closest ancestor) of the time element.
  1. <!DOCTYPE HTML>  
  2. <html>  
  3.     <body>  
  4.         <article>  
  5.             <time datetime="2011-01-28" pubdate="pubdate" ></time>  
  6. Article Date.  
  7.         </article>  
  8.     </body>  
  9. </html>  

Datetime Attribute

The DateTime attribute Specifies that the date or time for the time element.
For Example
  1. <!DOCTYPE HTML>  
  2. <html>  
  3.     <body>  
  4.         <div>  
  5.             <strong>Time:</strong>  
  6.             <br />  
  7.             <time datetime="2:00:00-05:00">2:00 PM</time>  
  8.         </div>  
  9.         <div >  
  10.             <br />  
  11.     Date and Time  
  12.             <br />  
  13.             <time xsi:type="xsd:dateTime"  
  14. datetime="2011-8-30T23:59:59-04:00">12/31/2010 11:59:59 PM</time>  
  15.             <br />  
  16.         </div>  
  17.         <div >  
  18.             <br />  
  19.     Date   
  20.             <br />  
  21.             <time datetime="2011-08-30">August 30, 2011</time>  
  22.             <br />  
  23.         </div>  
  24.     </body>  
  25. </html>  
Internet explorer