HTML datetime attribute

datetime attribute represents the machine-readable value of time. datetime attribute is used where a change in the text occurs i.e. when we insert or delete some text.

<p><del datetime="2012-08-07">task1 has been completed.</del></p>
<p><del datetime="2012-10-02">task2 has been completed.</del></p>
<p><ins datetime="2012-11-05">new task has been assigned.</ins></p>
</>

task1 has been completed.

task2 has been completed.

new task has been assigned.

Attribute values

All possible values of datetime attribute

datatime attribute is used by the browser.

The value of datetime attribute is a valid datetime string. There are many other attributes.

  • Month string (2012-05)

  • data string (2012-05-16)

  • yearless string (--06-24)

  • time string (12:05:35)

  • floating date and time string (2012-26-24T12:05:35)

  • time zone offset string (-11:35 or +12:00)

  • Global date and time string (12:05:35T12:00Z)

  • Week string (year-weak and weak=<52)(2012-25)

Related Tags

The tags that support datetime attribute

<del> tag

del attribute is used to represent the deleted text. datetime attribute indicates the date and time (optionally) of the deleted text.

<del datetime="2012-02-12">This is the deleted text.</del>
Try</>

<ins> tag

ins tag is used to represent the inserted text. datetime attribute represents the data and time of the inserted text.

<ins datetime="2012-05-11">Here the text has been inserted.</ins>
Try</>

<time> tag

This attribute represents the machine-readable value of the time in <time>.

<time>He will publish the novels after<time datetime="2012-02-12">two weeks.</time>
Try</>


Was this article helpful?