Reference · Beginner

The time element

Use time to pair a human-readable date, time, or duration with an optional machine-readable datetime value.

Published
Last checked

Definition

time represents a date, time, time-zone offset, or duration in a form that can be read by people and machines. The visible text may be conversational while the datetime attribute supplies a normalized value.

Minimal syntax

<p>Published <time datetime="2026-08-01">August 1, 2026</time>.</p>
<p>Estimated duration: <time datetime="PT45M">45 minutes</time>.</p>

If the element's text already uses a valid machine-readable form, datetime can be omitted. Adding it is often clearer when the visible format uses words.

Valid values and context

Use an ISO-style date for calendar dates, a time with an offset when the instant matters across time zones, and an ISO 8601 duration for elapsed time. Do not put an approximate phrase such as “later this summer” in datetime. The normalized value must match the visible claim rather than silently correcting it.

Browser and accessibility behavior

Browsers do not automatically localize or format time; it remains ordinary phrasing content unless application code changes it. Assistive technology may read the visible text without exposing the attribute, so write the displayed date clearly. Search systems and parsers may use the normalized value, but the element alone does not guarantee a rich result.

Common failures

  • The visible date and datetime attribute disagree.
  • A local meeting time omits its time zone where readers are distributed.
  • JavaScript rewrites dates differently on server and client, causing a hydration mismatch.
  • A date is marked up solely in hidden metadata and never shown to readers.

Verification checklist

Compare the visible and machine-readable values, including year, offset, and duration units. Test server and client rendering in more than one locale and time zone when formatting is dynamic. Confirm the date remains understandable with scripts disabled and that structured data, if present, repeats the same visible fact rather than inventing a second value.

For relative phrases such as “today” or “in two hours,” keep an unambiguous date available when the content may be archived, shared across time zones, or read later. Recheck scheduled content at the boundary where its wording changes.