<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
| Attribute | What it does |
|---|---|
datetime | Machine-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).