Dear Experts

I have followin codes

CSS

#footer {
	clear:both;
  width: 826px;
  height: 50px;
  background: rgb(0%, 80%, 40%);
  padding: 5px;
  margin: 0;
line-height: 50px;
}

HTML

<div id="footer">
Last Updated : January 01, 2012
  </div>

Footer tags is included in all 5 pages, When I update any page then I have to edit this line

Last Updated : January 01, 2012

in all pages

Is there a way to create variable to store last updated value.
Then this value must show in the footer div of every page.

Please help

Dani AI

Generated

A few practical options to stop editing five pages every time the date changes. and pointed you toward server-side includes — that is the right direction. If the site runs PHP, keep a single footer include but have that include compute the page's own modification time. A common trap is using the included file's mtime; instead read the calling script's file time with $_SERVER['SCRIPT_FILENAME'].

<?php
// footer.php (included on every page)
$mtime = filemtime($_SERVER['SCRIPT_FILENAME']);
echo 'Last Updated: ' . date('F j, Y', $mtime);
?>

If you prefer manual control (or your CMS tracks an edit timestamp), set a $lastUpdated variable in each page before including the footer; the footer can echo that variable when present and fall back to filemtime() otherwise. For static-only hosts without server-side code, enable Server Side Includes (.shtml) or add a build step (static site generator or deploy script) that injects the date. Client-side document.lastModified is another fallback but is unreliable for dynamic pages or when caching/CDNs are involved — prefer server-side solutions where possible.

PHP filemtime() is documented at filemtime documentation. For client-side behavior see document.lastModified — MDN.

Recommended Answers

All 2 Replies

I the website on a server with PHP available? A simple PHP include will let you reference the footer in each page but only require you to update it once (in the footer.php file you would create).
Although I always assumed that the date updated applied to that page in particular. If you only update page 1 should the updated date change for page 2?

I never tried this in html,

in classic asp or php, we will use a feature called SERVER SIDE INCLUDES

that is creating a seperate file html or asp , name it footer.html

then include this file all the pages

like below

<div><!--#include file="footer.html" -->
</div>

so you have to modify only one file footer.html , incase if you want to update

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.