The HTML DOM lastModified property returns the date and time the current document was last modified.
Syntax
Following is the syntax −
Returning date and time −
document.lastModified
Example
Let us see an example for HTML DOM lastModified property −
<!DOCTYPE html> <html> <head> <title>HTML DOM lastModified</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>HTML-DOM-lastModified</legend> <label for="textSelect">NOTICE: <input type="text" size="25" id="textSelect" value="Next Sunday will be a working" disabled> </label> <input type="button" onclick="getNoticeIssuedTime()" value="When was this issued?"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var textSelect = document.getElementById("textSelect"); function getNoticeIssuedTime() { divDisplay.textContent = 'Notice was issued on: '+document.lastModified; } </script> </body> </html>
Output
This will produce the following output −
Before clicking ‘When was this issued?’ button −
After clicking ‘When was this issued?’ button −