References

Beginner-friendly references for web development, with live, editable examples.

The HTML <time> tag

Element All modern browsers Updated
Quick answer

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

Live example
<p>Published on <time datetime="2026-06-22">22 June 2026</time>.</p>

Best practices

  • Always include the datetime attribute 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 datetime stays precise.
  • For machine-readable values that are not dates or times, use <data> instead.

Frequently asked questions

What is the time element for?
To represent a date, time or duration in both human-readable text and a machine-readable datetime value.
What format does the datetime attribute use?
ISO-8601 — for example 2026-06-22 for a date, 14:30 for a time, or PT2H for a duration.
Is the datetime attribute required?
Only when the visible text is not already a valid date/time string. It is best practice to include it regardless, for clarity and SEO.
Does the time element help SEO?
Yes. Search engines can read the datetime value for structured data such as publication dates and event times.