<time>
Example
<time datetime="May 1st">
May 1
</time><time datetime="2024-05-01">
May 1
</time>datetime must be a machine-readable date or time so search engines and scripts can parse it.
Common mistakes
- Putting a localized date string like 'May 1st' or '05/01' in
datetime. - Wrapping relative text like 'yesterday' in
<time>without adatetimeattribute.
Key points
- The
datetimeattribute uses a valid machine format, likeYYYY-MM-DDor a full ISO date and time. - Human-readable text inside
<time>matches thedatetimevalue.
Interview questions
Is the datetime attribute required?
datetime attribute required?Only when the element text is not itself in a valid date or time format.
Can <time> represent a duration?
<time> represent a duration?Yes. datetime accepts durations such as 'PT2H30M' for two and a half hours.