When looking at a suitable way of keeping a "Last Modified" date/time stamp on each of my pages loaded to the Freepages server at Rootsweb.com, I decided to make use of the server's Last_Modified time-stamp which can be appended to each page. This requires the following Server Side Includes (SSI) script to be added to the page:-
<!--#echo var="Last_Modified" -->
It is worth noting that these SSI commands are a subset of Perl language commands that are made available on the Rootsweb servers to enable the user to get some responses by using the #echo command, or as is more commonly used, the #include command which instructs the server to place a text file at a specific place on the page being served. In the case of the "Last_Modified" variable that we are interested in, the server creates a time-stamp at the precise time the page was loaded to the server and appends this to the page each time it is downloaded.
In its simplest form - <!--#echo var="Last_Modified" --> the ouput of the servers time-stamp is in the following format:-
Wednesday, 17-Sep-2008 03:42:12 MDT
This means little to anyone viewing the page at some remote location on the planet, as they don't know that the Rootsweb servers are located at Provo, Utah in the United States of America, and that MDT stands for Mountain Daylight Time. So it occured to me that it would be more use to see the time in a format easily recognised and meaningful to them. The outcome is a small piece of JavaScript which makes use of the server's time-stamp in two ways; firstly by getting the server to configure the Date/Time output in a way that can be manipulated, and secondly by having the server separately provide a Time Zone stamp. It is this Time Zone stamp that makes the script possible.
<object><noscript><span>Page Updated - <!--#echo var="Last_Modified" --></span></noscript></object>
<script type="text/javascript">
var sM = Date.parse('<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="Last_Modified" -->');
var sZ = ('<!--#config timefmt="%Z"--><!--#echo var="Last_Modified" -->');
d = new Date();
var uZ = d.getTimezoneOffset() * 60000;
if(sZ == 'MDT') sO = 6 * 3600000;
else if(sZ == 'MST') sO = 7 * 3600000;
msecs = sM + sO + (uZ * -1);
uM = new Date(msecs);
document.write('Page Updated - ' + uM)
</script>
Simply, the script detects the server's time-stamp plus its Time Zone offset from GMT/UTC (Greenwich Mean Time / Universal Coordinated Time), then detects the user's computer time and its Time Zone offset from GMT/UTC and adjusts the output time in terms of the user's Local Time. A more detailed description of how the script works can be found here.
The 'Last_Modified" time-stamp output configuration can be modified by addition of the '#config timefmt' - <!--#config timefmt="%B %d, %Y %H:%M:%S"--> e.g. "August 31, 2008 19:31:25" - and this is necessary to enable the JavaScript Date Object to understand (parse) the data it contains.
The first variable in the script - var sM (server last Modified) gets the information from Date.parse(); which contains instructions in the #config time format plus the #echo Last_Modified request.
Likewise, - var sZ (server time Zone) is obtained in the next line.
Output of the Date Object is in milliseconds (calculated from 00H 00M 00S 000mS on Jan 1, 1970) and the Time Zone data is either MDT or MST as provided by the %Z in the '#config timefmt'.
In the third line is d = new Date(), which creates a new Date Object to hold your Time Zone offset with the current time in London at the Greenwich Meridian (GMT/UTC). This new data is obtained using the getTimezoneOffset() method which provides the time difference in minutes between your computer's time and GMT/UTC.
The variable uZ (users Zone offset) in line four holds this time difference which has been converted from minutes into milliseconds by multiplying by 60 * 1000 (6000).
To determine which is the correct server Time Zone, an IF function is used to detect which of either 'MDT' or 'MST' has been provided by the time-stamp. If 'MDT' is found to be TRUE, then the calculated value of 6 hours x 60 minutes x 60 seconds x 1000 milliseconds is now stored in the new variable sO (server Offset). Should the preceding function be FALSE, then the ELSE IF function will test for 'MST' and do a similar calculation using 7 hours which is the server Offset to GMT/UTC.
Should you wish to use this script on a server in another location, e.g. Atlanta, GA, then 'MDT' and 'MST' should be replaced with 'EDT' and 'EST' respectively. The offset hour values must also be changed from 6 to 4, and 7 to 5 respectively. The offset hour values are 'positive' for Time Zones that lie to West of the Greenwich Meridian (GMT/UTC) and 'negative' (-) for Time Zones to the East of this meridian.
To use the script on a server located in Adelaide, South Australia, the relevant parts of the script should be changed to:-
if(sZ == 'ACDT') sO = -10.5 * 3600000;
else if(sZ == 'ACST') sO = -9.5 * 3600000;
From the values in the script you will note that Australian Central Standard Time (ACST) is 9H 30M 'ahead' of GMT/UTC, but the value we record is 'negative' (-) because the time at the Greenwich Meridian is 'behind' the Local Time in Adelaide.
Continuing with the operation of the script; the three variables, all converted to milliseconds - sM (server last Modified), sO (server time zone Offset) and uZ (user time zone Offset) are now added together. As sO is 'negative' (-) for Time Zones East of Greenwich, and 'positive' for those to the West, uZ is multiplied by -1 to ensure the correct total offset in milliseconds is obtained.
Example #1..
Server Time = August 31, 2008 19:31:25; Server in New York, NY on EDT; User in Olympia, WA on PDT
sO = 4 hours, uZ = 7 hours.
uM = 4 + (7 * -1) = -3; so Last Modified time in Olympia, WA is August 31, 2008 16:31:25 PDT
Example #2..
Server Time = August 31, 2008 19:31:25; Server in Christchurch, NZ on NZST; User in Dallas, TX on CDT
sO = -12 hours, uZ = 5 hours.
uM = -12 + (5 * -1) = -17 hours; so Last Modified time in Dallas, TX is August 31, 2008 02:31:25 CDT
Example #3..
Server Time = December 31, 2008 19:31:25; Server in Provo, UT on MST; User in Chatham Is, NZ on CIDT
sO = 7 hours, uZ = -13.75 hours.
uM = 7 + (-13.75 * -1) = 20.75 hours; so LM time in Chatham Is, NZ is January 1, 2009 14:16:25 CIDT
The final calculation in the script is to convert the Date and Time - uM = msecs - into a readable format. This is accomplished by creating another Date Object to hold the milliseconds value previously calculated, i.e. uM = new Date(msecs), and the document.write('Page Updated - ' + uM) returns your browser's version of the date, time and Time Zone.
Finally, this script is destined to become much shorter when the Document Object Method (DOM) is applied to it. Its operation will be the same but the amount of code to be copied to each page will reduce.
Alert eyes will have noted the additional line above the script containing Page Updated text and a further "Last Modified" time-stamp within <span> tags. This has been included so that if a user's JavaScript is off, the time-stamp will display the time as originally delivered by the server. When JavaScript is enabled, the code nested within the <object><noscript> tags is not displayed.
In order for the above script to work it must be placed on each page, as it is the time-stamp generated by the server when the file was uploaded that is appended to the script when the page is called by a user. One possible way of doing this, is to place the script in a <div> after the last paragraph on the page and before the container's closing </div>.  A possible coding example follows:-
<p>
Example text ..... "without any warranty of any kind, expressed or implied, or liability for its accuracy or omissions of any kind, nor for any loss or damage caused by a user's reliance on information obtained through this website, is given or implied".
</p>
<div style="margin-top:20px;font-family:verdana;font-size:18px;color:red;text-align:center;">
Highlight the complete script contained in the first block then Copy & Paste into the required location, then adjust the margin, font and color styles to suit.
For those of using HTML 4.01 Transitional and who prefer using tables, the following sample code may assist you in placing the script:-
<table><tr><td>
<p>
Example text ..... "without any warranty of any kind, expressed or implied, or liability for its accuracy or omissions of any kind, nor for any loss or damage caused by a user's reliance on information obtained through this website, is given or implied".
</p>
<center>
<font color="#cc6699" size="2">
Highlight the complete script contained in the first block then Copy & Paste into the required location, then adjust the font and color styles to suit.
Well that is all that needs to be done, and it is now necessary to load the page to the server in order for the time-stamp to show. Once the page is on the server, open it and refresh (Ctrl +F5 or Ctr +R). All things being equal, the new time-stamp will be displayed in terms of your Local Zone Time, and in a format determined by the browser in which the page is viewed.
<object><noscript><span>Page Updated - <!--#flastmod file="my_content.txt" --></span></noscript></object>
<script type="text/javascript">
var sM = Date.parse('<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#flastmod file="my_content.txt" -->');
var sZ = ('<!--#config timefmt="%Z"--><!--#flastmod file="my_content.txt" -->');
d = new Date();
var uZ = d.getTimezoneOffset() * 60000;
if(sZ == 'MDT') sO = 6 * 3600000;
else if(sZ == 'MST') sO = 7 * 3600000;
msecs = sM + sO + (uZ * -1);
uM = new Date(msecs);
document.write('Page Updated - ' + uM)
</script>
Finally, the script in the box above is specifically modified to enable a .html page which has its content updated using a SSI .txt file to show the latest update time of that file. Other than using the #flastmod command, the operation of the script is identical to the first one.