English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Encyclopedia

HTML: <time> tag

The HTML <time> tag ( <time>) is used to represent2412-hour clock time or Gregorian date, if representing a date, it can also include time and time zone. This element is intended to represent dates and times in a machine-readable format. Applications with scheduling features can take advantage of this.

Online example

How to define time and date:

!doctype html>
<html>
<head>
  <title>HTML5 time tag usage (Basic Tutorial Website oldtoolbag.com)</title>
  <meta charset="UTF-8">
</head>
<body>
<article>
  <h1>Heading for Article</h1>
  <p>Text that appears under article</p>
</article>
<footer>
  <p>This article was published on <time>2019-12-28</time>.</p>
  <p>Our business opens at <time>08:30</time>.</p>
</footer>
</body>
</html>
Test to see ‹/›
In this HTML5In the document example, we created two <time> tags-The first <time> tag displays the date, and the second <time> tag displays the time in24Time represented in the 12-hour clock format.

Browser compatibility

Browsers supported by <time>:

IEFirefoxOperaChromeSafari

Definition and usage of the tag

The <time> tag defines the Gregorian calendar time (24 hour system) or date, and the time zone offset is optional.

The element can encode dates and times in a machine-readable format, so that, for example, user agents can add birthday reminders or scheduled events to the user's schedule, and search engines can generate more intelligent search results.

HTML 4.01 and HTML5Differences between

<time> tag is an HTML5 New tag in

Attribute

New: HTML5 New attribute in

AttributeValueDescription
datetimeHTML5datetimeSpecify the date/Another way is to provide the date by the content of the element./Time.
pubdatedatetime(This attribute is still being considered by WHATWG and W3(indicating the date within the <time> element). / The time indicates the publication date of the document (or the nearest ancestor <article> element)

Global attributes

Support for <time> tag Global attributes of HTML.

Event attributes

Support for <time> tag HTML event attributes.