ins dateTime Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Ins

Description

The dateTime property sets or gets the datetime attribute of an inserted text, which identifies the date and time of when the text was inserted.

Set the dateTime property with the following Values

Value Description
YYYY-MM-DDThh:mm:ssTZD Sets 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 as Greenwich Mean Time)

Return Value

A String, representing the date and time of when the text was inserted

The following code shows how to return the date and time of when some text was inserted:

Demo Code

ResultView the demo 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>/* w  ww. j  ava 2  s.c o m*/

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

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

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

</body>
</html>

Related Tutorials