Javascript DOM HTML Document lastModified Property convert to Date object

Introduction

Convert the lastModified property into a Date object:

var x = new Date(document.lastModified);

Click the button to display the date and time this document was last modified.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//from   w w w. j  a v a 2 s. c  o  m
  var x = new Date(document.lastModified);
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related