HTML DOM ins dateTime Property



The HTML DOM ins dateTime property returns the date and time for when the text was inserted.

Syntax

Following is the syntax −

Returning string value

insObject.dateTime

Example

Let us see an example for ins dateTime property −

 Live Demo

<!DOCTYPE html> <html> <head> <title>ins dateTime</title> <style>    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       padding: 2px;       margin:5px;    }    input[type="button"] {       border-radius: 10px;    } </style> </head> <body> <form> <fieldset> <legend>ins-dateTime</legend> <h1>Fact:</h1> <p>Water cannot persist on moon's surface. <ins id="newInfo" cite="https://www.example.com/water-ice-moon-surface-confirmed.html" datetime="2018-08-21T18:23Z"> Water ice found on moon.</ins> </p> <input type="button" onclick="getDate()" value="When was this change made?"> <div id="divDisplay"></div> </fieldset> </form> <script>    var divDisplay = document.getElementById("divDisplay");    var insDateTime = document.getElementById("newInfo");    function getDate() {       divDisplay.textContent = 'Text inserted on '+insDateTime.dateTime.split("T")[0];       divDisplay.textContent += ' at '+insDateTime.dateTime.split("T")[1];    } </script> </body> </html>

Output

This will produce the following output −

Before clicking ‘When was this change made?’ button −

After clicking ‘When was this change made?’ button −

Updated on: 2019-07-30T22:30:26+05:30

110 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements