Javascript DOM HTML del dateTime Property get

Introduction

Return the date and time of when some text was deleted:

var x = document.getElementById("myDel").dateTime;

Click the button to return the value of the datetime attribute of the deleted text.

View in separate window

<!DOCTYPE html>
<html>
<body>

<p><del id="myDel" datetime="2020-11-15T22:55:03Z">This text has been deleted</del></p>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  w  w  w .  j a  va2s . com
  var x = document.getElementById("myDel").dateTime;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The dateTime property sets or gets the value of the datetime attribute of a deleted text.

The datetime attribute sets the date and time when the text was deleted.

The datetime attribute has no visual effect in web browsers.

The dateTime property accepts and returns a String type value.

Property Values

Value
Description
YYYY-MM-DDThh:mm:ssTZD The date and time of when the text was deleted.
YYYY - year (e.g. 2012)
MM - month (e.g. 01 for January)
DD - day of the month (e.g. 08)
T - a required separator
hh - hour (e.g. 22 for 10.00pm)
mm - minutes (e.g. 55)
ss - seconds (e.g. 03)
TZD - Time Zone Designator (Z denotes Zulu, which is Greenwich Mean Time)



PreviousNext

Related