<time> Date or time

Marks a date, time or duration and gives it a machine-readable value.

<time> marks a date, time or duration. The visible text can be written for people (3 May), and the datetime attribute carries a precise, machine-readable form such as 2026-05-03, 14:30 or 2026-05-03T14:30.

Search engines, calendars and browser tools can all read it. Leave out datetime and the visible text itself has to be in a valid format. People get this wrong a lot.

Every valid datetime format, from dates to durations, is listed in the time element in the HTML Living Standard (opens in a new tab). Other machine-readable values go in the data element.

Syntax

<time datetime="2026-10-22">22 October 2026</time>

When to use it

A <time> element belongs wherever a page shows a specific date, time or duration: the publish date of a blog post, an event start time, opening hours, a recipe's cooking time, or a year or month on its own (2026, 2026-10).

Only precise values can be marked. Vague phrases like "next spring" or "soon" have no valid datetime, so leave them as text. For numbers that are not dates or times, such as prices or product codes, use data.

Time zones trip up anything with an audience in more than one place. datetime="2026-11-05T18:30" is a floating local time that tools cannot place on a timeline. For an online event, add the offset, such as 2026-11-05T18:30+01:00, or use UTC with Z, and also name the time zone in the visible text. For durations, use formats like PT1H15M or 1h 15m.

Attributes

AttributeWhat it does
datetimeMachine-readable value: YYYY-MM-DD, HH:MM, a full date-time or a duration like PT2H.

Live example

Edit the code and watch the preview.

<p>The concert starts at <time datetime="20:00">8 pm</time> on <time datetime="2026-07-14">14 July</time>.</p>
<p>Posted <time datetime="2026-05-03T09:15">3 May, 9:15</time>.</p>

More examples

Cooking time as a duration

The datetime attribute can hold a duration. PT means a period of time, followed by hours (H) and minutes (M). The visible text stays friendly for people. Search engines and recipe tools can read these values.

<h2>Pancakes</h2>
<ul>
  <li>Prep time: <time datetime="PT15M">15 minutes</time></li>
  <li>Cooking time: <time datetime="PT1H15M">1 hour 15 minutes</time></li>
</ul>

Event with a time zone offset

An online class has viewers in many countries. The datetime value includes the offset from UTC, and the visible text names the time zone, so both people and tools know the exact moment.

<p>Live pancake class: <time datetime="2026-11-05T18:30+01:00">5 November 2026, 18:30 Central European Time</time>.</p>

Tip: Text written for humans always needs a datetime too.

Browser support

time is part of HTML5 and the Living Standard, and all current browsers support it. Browsers that predate it simply show the text as an unknown inline element. The dateTime DOM property arrived later in some browsers; see the time element support table (opens in a new tab).

Accessibility

Screen reader users hear only the visible text, never the datetime value, so write the date unambiguously, such as 22 October 2026. The overview of date formats by country (opens in a new tab) shows why: 03/04 is a different day depending on where you live.

Common mistakes

Wrong

<time datetime="22/10/2026">22 October</time>

Right

<time datetime="2026-10-22">22 October</time>

datetime needs the YYYY-MM-DD format. Local formats are invalid.

Frequently asked questions

What format does the datetime attribute use?

ISO 8601-style values. A date is 2026-10-22, a time is 14:30, and a combined value is 2026-10-22T14:30 with an optional time zone like Z or +02:00. A month is 2026-10, and a duration looks like PT2H30M. The datetime attribute takes these, while the visible text can be in any human-friendly form. The date part follows the international standard ISO 8601 (opens in a new tab).

Does the time tag help SEO?

A little, indirectly. It gives search engines and other tools an unambiguous date for things like publish dates and event times, which can help them show dates correctly. They lean mainly on structured data and visible dates, though, so pair <time> with clear visible dates and do not expect it to move rankings by itself. For events, Google reads dates from structured data such as schema.org Event (opens in a new tab).

Related text elements

<p>One paragraph of text.<br>Breaks the line inside text, as in a postal address or a poem.<hr>A change of topic between paragraphs, drawn as a horizontal line.<pre>Shows text exactly as typed, spaces and line breaks included.<blockquote>A longer quotation from another source, set apart as its own block.<div>A generic block box with no meaning, for grouping and styling.<span>A generic inline wrapper with no meaning, for styling part of a line of text.<strong>Text that is important, serious or urgent. Shown in bold by default.<em>Stress emphasis that changes what a sentence means. Italic by default.<b>Makes text stand out without adding importance, as with keywords. Bold by default.<i>Text in another voice: foreign words, terms, thoughts, ship names. Italic.<u>Text with an unspoken annotation, such as a flagged spelling error.<s>Content that is no longer accurate or relevant, drawn crossed out.<mark>Highlighted text, like a marker pen, showing relevance in the current context.<small>Side comments and fine print, like copyright lines or legal notes.<sub>Subscript text, set below the line, as in H2O.<sup>Superscript text, set above the line, as in exponents or 1st.<code>A fragment of computer code, set in a monospace font.<kbd>Keys or text the user should press or type.<samp>Sample output from a program or a computer system.<var>A variable in math or in code. Italic by default.<q>A short quotation inside a sentence. The browser adds the quote marks.<cite>The title of a creative work: a book, film, song, game or article.<abbr>An abbreviation or acronym, with an optional expansion in title.<dfn>Marks the term that the surrounding sentence or paragraph defines.<data>Ties visible content to a machine-readable value.<del>Text that was removed from the document. Struck through by default.<ins>Text that was added to the document. Underlined by default.<wbr>A spot where the browser may break a long word if it has to.<bdi>Isolates text of unknown direction, such as user names.<bdo>Forces a text direction and overrides the normal bidi algorithm.<ruby>Small annotations above or beside text, mostly for East Asian pronunciation.<rt>The small reading or note in a ruby annotation.<rp>Fallback brackets around ruby text, shown only where ruby is unsupported.