Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

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__)); ?>
share|improve this answer
    
And rename your yourpage.html into yourpage.php –  Marco Demaio 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

Update:

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

share|improve this answer
    
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. –  Marco Demaio Jan 30 '11 at 15:42

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.