Javascript Reference - HTML DOM del dateTime Property








The datetime attribute sets when the text was deleted.

The dateTime property sets or gets the datetime attribute for del element.

Browser Support

dateTime Yes Yes Yes Yes Yes

Syntax

Return the dateTime property:

delObject.dateTime 

Set the dateTime property:

delObject.dateTime = YYYY-MM-DDThh:mm:ssTZD;

Property Values

Value Description
YYYY-MM-DDThh:mm:ssTZD When the text was deleted.
  • YYYY - year (e.g. 2015)
  • MM - month (e.g. 01 for January)
  • DD - day of the month (e.g. 09)
  • T - a required separator
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 52)
  • ss - seconds (e.g. 04)
  • TZD - Time Zone Designator




Return Value

A string value of when the text was deleted.

Example

The following code shows how to set the datetime attribute.


<!DOCTYPE html>
<html>
<body>
<del id="myDel" datetime="2012-12-12T22:22:03Z">deleted</del>
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from  ww w . j  a  va  2s .  c  o  m-->
    document.getElementById("myDel").dateTime = "2015-15-15T21:45:07Z";
    document.getElementById("demo").innerHTML = "changed";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get when text was deleted.


<!DOCTYPE html>
<html>
<body>
<del id="myDel" datetime="2011-11-11T21:51:03Z">deleted</del></p>
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from   ww  w .  ja va  2 s.  c o  m-->
    var x = document.getElementById("myDel").dateTime;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: