HTML datetime Attribute

The datetime attribute attaches a datetime value to an element.

This value is not visible, but it is machine-readable.

Elements that accept datetime include <del>, <ins>, and <time>.



A <del> element with a datetime attribute.
The datetime value signifies when the deletion occurred.

Your order has been canceled cancelled.

  Your order has been 
  <del datetime="2020-11-25T09:10:43">canceled</del> 

For additional details see our HTML time datetime Reference.

Using datetime

The datetime attribute attaches a date (required) and time (optional) value to an element.

Its value is not visible to the user; it only adds a semantic timestamp to the element.

The datetime values are readable by screen readers, search engines, JavaScript code, and others.


<tagname datetime="YYYY-MM-DDThh:mm:ssTZD" >



DESCRIPTION: The date and time attached to the element.
The format can be broken down as follows:
  • YYYY - year (e.g. 2020)
  • MM - month (e.g. 09 for September)
  • DD - day (e.g. 01 for first day of the month)
  • T or space - a date and time separator, required if date is included
  • hh - hour in 24-hour format (e.g. 23)
  • mm - minutes
  • ss - seconds
  • TZD - Time zone designator where Z refers to Zulu or GMT
  • P - prefix for period (duration)
  • D - prefix for days
  • H - prefix for hours
  • M - prefix for minutes
  • S - prefix for seconds
EXAMPLES: local time
2021-01-18 11:54:41.809
international time
2021-01-18 18:54:41.809Z

Elements that accept datetime

The following elements accept the datetime attribute.

Elements Description
<del> Specifies a deleted text -- see example above.
<ins> Specifies an inserted text.
<time> Specifies a date and time

<ins> with datetime

An <ins> tag with a datetime attribute.

HTTP stands for Hypertext Translate Transfer Protocol.

  HTTP stands for Hypertext 
  <ins datetime="2020-10-02T08:11:08Z">Transfer</ins> 

For additional details see our HTML ins datetime Reference.

<time> with datetime

A <time> tag with a datetime attribute.

The date is: .
The time is: .

  The date is: <time datetime="2020-08-07">August 7, 2020</time>.<br />
  The time is: <time datetime="15:22">3:22 PM</time>.

For additional details see our HTML time datetime Reference.

Browser support

Here is when datetime support started for each browser:

62.0 Oct 2017
22.0 Jun 2013
18.0 Jan 2020
49.0 Nov 2017
7.0 Oct 2013

You may also like

Last updated on Sep 30, 2023