HTML <time> Tag

The <time> tag is a new element in HTML5. It is used to define a human-readable time on a 24-hour clock or a precise date in the Gregorian calendar. The datetime attribute is used to define machine-readable format, which allows search engines to produce smarter results and user agents to add reminders to the user’s calendar.

Syntax

The <time> tag comes in pairs. The content must be written between opening (<time>) and closing (</time>) tags.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document.</title>
  </head>
  <body>
    <p>The game will be held on <time datetime="2018-09-28 19:00">September 28</time>.</p>
    <p>It will start at <time>19:00</time></p>
  </body>
</html>

Result

Attributes

Attribute Value Description
datetime Indicates the time and/or date of the element in the formats described below.
YYYY - a four-digit year
MM - a two-digit month, 01 - 12
DD - a two-digit day, 01 - 31
T -specifies that a time value follows.
hh -a two-digit hour, 00 - 24
mm - a two-digit minute, 00 - 59
ss -a two-digit second, 00 - 59
TZD - (Time Zone Designator) time zone

The <time> tag also supports the Global Attributes.

Browser support

6+ 9+ 4+ 5+ 11.1+