The datetime
attribute specifies when the text was inserted.
The dateTime
property sets or gets the value of the datetime attribute.
The dateTime property is supported in all major browsers.
![]() |
![]() |
![]() |
![]() |
![]() |
|
---|---|---|---|---|---|
dateTime |
Yes | Yes | Yes | Yes | Yes |
Return the dateTime property.
var v = insObject.dateTime
Set the dateTime property.
insObject.dateTime=YYYY-MM-DDThh:mm:ssTZD
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD | Specifies when the text was inserted.
|
A String type value representing of when the text was inserted.
The following code shows how to change the datetime attribute.
<!DOCTYPE html>
<html>
<body>
<ins id="myIns" datetime="2014-04-14T24:54:04Z">This is an inserted text.</ins>
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<!-- w w w .j a v a 2 s. co m-->
<script>
function myFunction() {
document.getElementById("myIns").dateTime = "2014-10-10T20:40:07Z";
document.getElementById("demo").innerHTML = "changed";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get when the text was inserted.
<!DOCTYPE html>
<html>
<body>
<ins id="myIns" datetime="2014-02-15T12:56:03Z">This is an inserted text.</ins>
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w ww . ja v a 2 s . co m-->
var x = document.getElementById("myIns").dateTime;
document.getElementById("demo").innerHTML=x;
}
</script>
</body>
</html>
The code above is rendered as follows: