I have a personal website that has around 4 - 5 HTML pages that I modify on a local editor (Kompozer) and then upload it to my website running on Apache.

I have seen many a times, pages have the footer as: 'Last modified date: ' or something like this, the date when the page was last updated.

How do I do the same for a HTML page? Is it possible?


If using PHP, just add this string in your HTML pages:

<?php echo "Page last modified: " . date ("F d Y H:i:s.", filemtime(__FILE__)); ?>
  • And rename your yourpage.html into yourpage.php Dec 22 '10 at 11:30
  • Sorry for being a noob, but the rest of the page can remain exactly the same?
    – Tim
    Dec 22 '10 at 11:39
  • Yep Tim, so long as you have PHP engine running, just add this anywhere and the part between <?php ... ?> will be interpreted by the PHP engine and output nicely the result. Welcome to the Era of Dynamic ServerSide Generated Pages! (im new here too and PHP is very clever and exciting thing!)
    – Sam
    Dec 22 '10 at 16:32

If you want to keep it as an HTML page with no server side scripting, you can use Javascript to get the date last modified.

Instructions here


W3Schools (I know not always the most reliable source, but worth a look for this) has this to say

  • thanks +1 is due here, I didn't know about the JS document.lastModified property. Do you know anything about the browsers' support for this property. Jan 30 '11 at 15:42
  • I'm not sure about Webmaster's stack exchange, but other stack exchanges frown upon link-only answers. Perhaps you should provide the code to do it?
    – user40589
    Nov 27 '15 at 1:52

What editor are you using to edit the page? Many WYSIWYG editors (as well as some text-based ones) allow you to insert automatically-updated time/date fields. If you don't want to use PHP or some other server-side language, then this would be the easiest way to do it. For example, in DreamWeaver, you just click on the "Insert Date" button and check the "Update automatically on save" box.

Though if you're not too scared of programming and you're interested in build websites professionally, I would highly recommend you just learn a server-side scripting language like PHP/Python/Ruby/JSP/ASP/etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy