Last Modified Date
Keep content transparent. This script automatically displays the date and time the current HTML file was last saved to the server.
This page was last modified on:
Copy the Script
<p>Last Updated: <span id="modDate"></span></p>
<script>
// Basic Usage
document.getElementById("modDate").innerHTML = document.lastModified;
// Advanced Formatting
/*
var d = new Date(document.lastModified);
document.write(d.toLocaleDateString());
*/
</script>
Frequently Asked Questions
For static HTML files, it works perfectly (showing when you uploaded the file). For PHP/database pages, it might show the current time (since the page is generated on the fly).
Yes. `document.lastModified` returns a string. You can pass it into `new Date(document.lastModified)` to format it using standard date methods.
Yes. Showing a 'Last Updated' date helps users and search engines know that your content is fresh.