document.lastModified of a page
JavaScript
document
WE can collect the last modified or created date of the current file by using document object lastModified property.
Here is the syntax
document.write(document.lastModified);
The above command is case sensitive
The output of current page is here
Here is the complete code for you to try.
<html>
<head>
<title></title>
<script type="text/javascript">
document.write(document.lastModified);
</script>
</head>
<body>
</body>
</html>
Creating Date object
Date Object and formats →
<script type="text/javascript">
var dt= new Date(document.lastModified) // Date object
var str=dt.getDate() +'/'+dt.getMonth()+'/'+dt.getFullYear() // date/month/year
document.write(str);
</script>
Output
← document Object Sending output to screen →
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
plus2net.com