Javascript DOM HTML ins dateTime Property get

Introduction

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

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<p>This is a text.
<ins id="myIns" datetime="2012-09-15T22:55:03Z">This is an inserted text.</ins>
</p>/*from   w ww . j a  v a2s. co m*/
<p id="demo"></p>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
  var x = document.getElementById("myIns").dateTime;
  document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

The dateTime property sets or gets the value of the datetime attribute of an inserted text.

The datetime attribute sets the date and time of when the text was inserted/changed.

The datetime attribute has no visual effect in ordinary web browsers.

The dateTime property returns a String type value.

Value
Description
YYYY-MM-DDThh:mm:ssTZD








Specifies the date and time of when the text was inserted/changed.
YYYY - year (e.g. 2009)
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 Greenwich Mean Time)

The dateTime property returns a String representing the date and time of when the text was inserted.




PreviousNext

Related