Skip to main content

require-datetime

Warn to need the datetime attribute if the time element has invalid content.

The time element represents its contents, along with a machine-readable form of those contents in the datetime attribute. The kind of content is limited to various kinds of dates, times, time-zone offsets, and durations, as described below.

The datetime attribute may be present. If present, its value must be a representation of the element's contents in a machine-readable format.

Cite: HTML Living Standard 4.5.14 The time element

❌ Examples of incorrect code for this rule

<time>1/5/2023</time>
<time>Today</time>
<time>令和5年1月5日</time>

✅ Examples of correct code for this rule

<time>2023-01-05</time>
<time datetime="2023-01-05">1/5/2023</time>
<time datetime="2023-01-05">Today</time>
<time datetime="2023-01-05">令和5年1月5日</time>

Interface

{
"require-datetime": boolean
}

Options

{
"require-datetime": {
"options": {
"langs"?: ("en" | "ja" | "fr" | "nl" | "ru" | "de" | "pt" | "zh")[]
}
}
}
PropertyTypeDefault ValueDescription
langs("en" | "ja" | "fr" | "nl" | "ru" | "de" | "pt" | "zh")[]["en","ja","fr","nl","ru","de","pt","zh"]Specify languages that are parsing the content, and its order. They are parsable depending on Chrono.

Default Severity

error