The <time> element
The <time> tag marks a date, a time or a duration in a way computers can read. Readers see friendly text like “next Friday at 3pm”, while the datetime attribute holds a standard value like 2026-10-09T15:00. Search engines, browsers and scripts can use that value for calendars, sorting and search results.
Last updated: October 3, 2026
Quick facts
| Category | Flow content, phrasing content, palpable content |
| Content model | Phrasing content; if there is no datetime attribute, the text itself must be a valid date/time |
| Tag omission | Neither the start nor the end tag can be omitted |
| Permitted parents | Any element that accepts phrasing content |
| DOM interface | HTMLTimeElement |
Syntax
Live example
Edit the code below and watch the preview update instantly.
Common datetime formats
| Value | Meaning |
|---|---|
| 2026-10-09 | A date |
| 2026-10 | A month |
| 15:00 | A time (24-hour clock) |
| 2026-10-09T15:00 | A date and time |
| 2026-10-09T15:00Z | A date and time in UTC (or add an offset like +08:00) |
| PT2H30M | A duration: 2 hours 30 minutes |
Attributes
| Attribute | Description |
|---|---|
| datetime | The machine-readable date, time or duration. Required unless the element’s text is already in a valid format. |
Common examples
A blog post date
Readers see a friendly date; the datetime attribute gives machines the exact ISO format.
An event with a start time
Add a time after a T. Include the time zone offset if visitors may be in other countries.
A duration
Durations use the ISO format starting with P (period) — PT1H30M is 1 hour 30 minutes.
Showing “3 days ago” with JavaScript
Keep the exact date in datetime and let a script turn it into relative text.
<time> vs <data>
Both pair human-friendly text with a machine-readable value. <time> is only for dates, times and durations, and its datetime value must follow the ISO date format. <data> is for every other kind of value, such as a product number or a price, stored in its value attribute.
So “October 3” belongs in <time>, while “Small (SKU 4821)” belongs in <data value="4821">.
| <time> | <data> | |
|---|---|---|
| For | Dates, times, durations | Any other value |
| Attribute | datetime | value |
| Format | ISO 8601 | Anything |
Common mistakes to avoid
- A
datetimein the wrong format. “03/10/2026” is ambiguous; always write2026-10-03(year-month-day). - Wrapping text that isn’t a date. “Soon” or “next season” can’t be turned into a precise value, so leave them as plain text.
- Leaving out
datetimeon friendly text. “Last Tuesday” needs adatetimevalue, or machines can’t read it. - Forgetting the time zone for events. 18:00 means different moments around the world; add an offset like
-05:00orZfor UTC.
Accessibility & SEO tips
- Show both published and updated dates on articles — readers trust fresh content, and search engines may show the date in results.
- Match your visible dates to the
datePublishedanddateModifiedvalues in your structured data. - Write dates in a format your audience recognises; the
datetimeattribute takes care of machines. - Use
<time>for opening hours and event schedules too, so calendar tools and assistants can read them reliably.
Browser support
Supported in all modern browsers, including Chrome, Edge, Firefox, Safari and their mobile versions. It was introduced with HTML5, and only very old browsers such as Internet Explorer 8 needed workarounds. The element itself has no default styling, so it looks like normal text everywhere.