Home / Software / Adding "last modified" code to your PHP website

Adding "last modified" code to your PHP website

PHP code
Question: How can I use PHP to display the “last modified” date on my website’s main page?

Answer: For any type of website that includes factual information, it is important to tell users when the information was added to the site. Information that was relevant five years ago might not be so today. Using a “last modified” line at the bottom of the page is a standard way of accomplishing this.

If you are running PHP and have a content management system, it is sufficient to put the “last modified” code at the bottom of the index.php page or its corresponding template. That way, every time someone accesses any page on the site, the last modified code will be executed.

Edit your PHP file, and enter the following code:

The information after “//” is just a comment to remind you of what the code does. Save the file and re-upload it to your server (if necessary), and you are all done.

Photo: Flickr

Check Also


Importance of web hosting to business

The world of business is very ruthless and unfair in some cases. It is a …