HTML <time> datetime Attribute

HTMLWeb DevelopmentFront End Technology

The datetime attribute of the <time> element is used to display the machine-readable date time.

Following is the syntax −

<time datetime="YYYY-MM-DDThh:mm:ssTZD">

Above, the attribute datetime displays the datetime −

  • YYYY - year
  • MM - month
  • DD - day of the month
  • hh - hour
  • mm - minutes
  • ss - seconds
  • TZD - Time Zone Designator

You can also set PTDHMS −

  • P - prefix for "Period"
  • D - prefix for "Days"
  • H - prefix for "Hours"
  • M - prefix for "Minutes"
  • S - prefix for "Seconds"

Let us now see an example to implement the datetime attribute of the <time> element −


 Live Demo

<!DOCTYPE html>
   <h2>Exam Results</h2>
   <p><s>Result would be announced on 6th June.</s></p>
   <p>New date for results is next <time datetime="06-15">Saturday</time>.</p>


Published on 21-Jun-2019 12:02:15