A document in its lifetime will undergo many changes. Javascript has provided a command called document.lastModified to get the instance when the document is last modified. This command will provide the exact date and time of modification.
syntax
Time = document.lastModified;
Example-1
In the following example, using the document.lastModified method the documents last modification date and time are displayed as shown in the output.
<html> <body> <script> document.write("This document is lastly modified on" + " " +document.lastModified); </script> </body> </html>
Output
This document is lastly modified on 07/29/2019 15:19:41
Example-2
In the following example, using the document.lastModified method the documents last modification date and time are displayed as shown in the output. When I modified the document the date and time are 07/29/2019 15:26:23.
<html> <body> <p>This document was last modified <span id="modify"></span>.</p> <script> document.getElementById("modify").innerHTML = document.lastModified </script> </body> </html>
Output
This document was last modified 07/29/2019 15:26:23.