← Community home

Why use datetime on a time element?

Community › Forums › Semantic HTML › Why use datetime on a time element?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #72

    A date should be readable to people and unambiguous to software.

    #73

    Detailed answer

    Visible text can use a friendly date format while datetime carries a machine-readable value.

    Use valid syntax and supply timezone information when representing a particular instant. This preserves meaning without forcing readers to see technical formatting. Publish genuine dates rather than backdating learning posts to imitate historic activity.

    Example

    <p>Updated <time datetime="2026-10-22">22 October 2026</time></p>

    Understanding the behavior

    Datetime gives time-related text a machine-readable representation while allowing a human-friendly label. Use a valid value that matches the visible meaning. If a precise moment matters across time zones, include an appropriate offset in a full date-time value.

    Practical implementation notes

    Do not encode a vague phrase as an invented exact timestamp. For a publication date that only needs a calendar day, a date-only value can be clearer than adding an arbitrary time.

    How to check it

    Inspect datetime and compare it with the visible date; add an offset when describing a precise instant.

    Expected result

    The machine-readable value describes the same date or instant shown to readers.

    Watch out: A date alone does not identify a timezone-specific event instant.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.