The HTML <time> tag
The HTML <time> element represents a date or time, with a machine-readable value in its datetime attribute. This lets browsers, search engines and assistive tech understand a human-friendly date — and powers rich results like event dates.
Overview
The <time> element pairs human-readable text with a machine-readable value in its datetime attribute, written as an ISO-8601 date, time, or duration. So you can display "June 22, 2026" to readers while machines read 2026-06-22.
That machine-readable value is genuinely useful. Search engines use it for structured data — article publish dates, event start times — which can enhance how your pages appear in results, and browsers or scripts can offer features like "add to calendar" from it.
If the visible text is already a valid date or time string, the datetime attribute is technically optional, but including it is best practice for clarity and reliability — especially when the displayed text is informal (like "last Tuesday"). Use it for specific dates and times; for other machine-readable values, its general-purpose cousin is <data>.
Syntax
<time datetime="2026-06-22">June 22, 2026</time>
Attributes
The <time> element supports the following attributes, in addition to the global attributes available to every HTML element.
| Attribute | Value | Description |
|---|---|---|
datetime |
A valid date/time string, e.g. 2026-06-22, 14:30 or 2026-06-22T14:30. |
Gives a machine-readable date/time. |
Example
<p>Published on <time datetime="2026-06-22">22 June 2026</time>.</p>
Best practices
- Always include the
datetimeattribute in a valid ISO-8601 format for reliable machine reading. - Use it for publish dates and event times so search engines can build structured data from them.
- Keep the visible text human-friendly while
datetimestays precise. - For machine-readable values that are not dates or times, use <data> instead.
Frequently asked questions
What is the time element for?
datetime value.What format does the datetime attribute use?
2026-06-22 for a date, 14:30 for a time, or PT2H for a duration.Is the datetime attribute required?
Does the time element help SEO?
datetime value for structured data such as publication dates and event times.