datetime (HTML attribute)

Spec
Depr. Version
No HTML 4
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Partial Partial Partial Partial Partial

Syntax

datetime="datetime"

Description

The datetime attribute contains the time stamp that reflects the time and date at which the change was made to the content using the ins or del elements. This attribute must be formatted precisely, right down to the minute and second.

Example

The datetime attribute is used in both the del and ins elements below:

<p>Bernie enjoyed nothing more than a <del
    cite="http://berniesworld.com/drag.html"
    datetime="2007-11-05T23:31:05Z">night out on the town at his
    favorite drag queen show</del> <ins
    cite="http://berniesworld.com/drag.html"
    datetime="2007-11-05T23:33:32Z">quiet night in with a warm cup of
    cocoa</ins></p>

Value

The datetime attribute is defined as follows (using the ISO8601 date format):

YYYY-MM-DDThh:mm:ssTZD

Here’s what the various components mean:

  • YYYY: year (e.g. 2007)
  • MM: month (e.g. 11 for November)
  • DD: day of the month (e.g. 05)
  • T: required character, a separator
  • hh: hour (e.g. 23 for 11.00pm)
  • mm: minutes (e.g. 31)
  • ss: seconds (e.g. 05)
  • TZD: Time Zone Designator (Z, which appears in the example HTML above, denotes Zulu, better known as Greenwich Mean Time.)

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial Partial

None of the browsers we tested do anything visual with the datetime attribute, but the information is available in the DOM for the purposes of scripting or styling with CSS. Given the nature of how different industries might want to handle/render the way that document changes are indicated to the user, a legal firm’s requirements for rendering a change that has an associated citation included in the markup may differ greatly from that, say, of a leisure center’s health and safety team. How they appear could be radically changed to suit these needs, but by default the browser does not include the information contained in the datetime attribute on screen to the user.

The compatibility chart is set to partial, because the information is there for the taking but the browser does not give any hint that there is date and time information available regarding this inserted text, only that there has been an insertion (with the italic font).

User-contributed notes

There are no comments yet.

Related Products