Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

time — machine-readable dates and times

The `time` element marks up a date, time, or duration. Its `datetime` attribute pairs reader-friendly text with an unambiguous machine-readable representation.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<time datetime="YYYY-MM-DD">human-readable date</time>

time gives its contents date- or time-related meaning. The optional datetime supplies their machine-readable equivalent. Without it, the text itself must use an allowed format, and the element must have no element descendants. Both tags are required.

Allowed representations include a month 2026-11, date 2026-11-18, yearless date 11-18, time 14:30, local date and time 2026-11-18T14:30, offset +01:00, global date and time 2026-11-18T14:30Z, week 2026-W47, year 2026, and duration PT30M. A year requires at least four ASCII digits and cannot be zero. Dates must be calendar-valid.

A local date and time does not identify a single global instant; a global representation includes Z or a UTC offset. An offset is not a geographic time-zone name.

In the example, the text and datetime describe the same date. The DOM property dateTime reflects the datetime attribute; the expected console output is 2026-11-18.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Time example</title>
<p><time id="event" datetime="2026-11-18">18 November 2026</time></p>
<script>
  const eventTime = document.getElementById('event');
  console.log(eventTime.dateTime);
</script>
</html>

Result

2026-11-18

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources