<time>
A date, time, or duration written clearly for people and, at the same time, understandably for machines.
- Display
- inline
- Closing tag
- Required
- Permitted content
- Phrasing content. Without the
datetimeattribute, only text in a valid format
Example
#<p>The webinar "Your First HTML Page" starts <time datetime="2026-10-06T18:00-04:00">October 6 at 6 PM</time>.</p>
<p>Recording length: <time datetime="PT1H15M">1 hr 15 min</time>.</p>Definition and usage
#The <time> element marks a date, time, or duration. You write the visible text for people, however you like ("tomorrow at 6 PM," "September 14"), and in the datetime attribute you give the same information in a strictly defined format, e.g. 2026-09-14 or 18:00.
Thanks to this, the exact date can be read by search engines, calendars, browser extensions, and your own scripts, regardless of the page’s language. A script could, for example, turn it into "3 days ago" or convert the time to the user’s own time zone.
If you leave out datetime, the element’s own content must be written in a valid machine format. Browsers don’t change the appearance of <time>, so to the reader it’s just plain text.
Syntax
#<time datetime="2026-09-28">September 28, 2026</time>Attributes
#date, time, or duration
The machine-readable version. A date has the formYYYY-MM-DD, a timeHH:MM, and combining both with the letterTand a time zone offset looks like this:2026-09-28T18:30-04:00. A duration starts with the letterP, e.g.PT1H30Mis an hour and a half, andP3Dis three days.
The element also supports all global attributes, such as class, id, style and hidden.
Attributes in practice
#datetime
date, time, or durationThe machine-readable version. A date has the form YYYY-MM-DD, a time HH:MM, and combining both with the letter T and a time zone offset looks like this: 2026-09-28T18:30-04:00. A duration starts with the letter P, e.g. PT1H30M is an hour and a half, and P3D is three days.
<ul>
<li><time datetime="2026-09-28">September 28, 2026</time></li>
<li><time datetime="2026-09">September 2026</time></li>
<li><time datetime="18:30">6:30 PM</time></li>
<li><time datetime="2026-09-28T18:30-04:00">today at 6:30 PM</time></li>
<li><time datetime="P3D">3 days</time></li>
</ul>Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- For events, give the time zone offset, e.g.
-04:00, so the time doesn’t get mixed up for participants in other countries. - Write an article’s publish date in
<time>, usually in the post’s<header>. - Don’t use
<time>for vague expressions with no specific date, such as "someday" or "soon."
Related entries
#- <data>Links human-readable content to a machine value, for example a product name with its code.
- <article>Self-contained content that makes sense read or shared on its own.
- <abbr>An abbreviation or acronym, with an optional expansion in the title attribute.
- <span>A generic inline container with no meaning, for styling a piece of text.
Spotted a mistake or missing an example? Write to us.