Mitsules, Mark
Mark.Mitsules at ngc.com
Fri Jun 20 09:16:32 CDT 2003
Group,
I am not familiar with JavaScript. On each departmental webpage I would
like to place the last "Modified" date (as would be reported from the
operating system). The routine below was emailed to me as is, but, when
implemented, seems to provide only today's date. Can anyone spot the
problem and provide a solution?
Does it make a difference that these pages are .stm (using server-side
includes) instead of .htm? Is it a problem with how I implement it?
<!-- BEGIN LAST UPDATE AREA -->
<TABLE WIDTH="100%"
CELLSPACING="0"
CELLPADDING="0">
<TR>
<TD ALIGN="RIGHT">
<FONT SIZE="1">
<SCRIPT language="JavaScript"
SRC="http://intranet/divisions/mydivision/mydepartment/Scripts/LastUpdated.j
s">
</SCRIPT>
</FONT>
</TD>
</TR>
</TABLE>
<!-- END LAST UPDATE AREA -->
Mark
<!-- hide script from old browsers
function getLongDateString()
{ //method defined on class Date.
//Returns a date string of the form: Day DD Month,YYYY
//(e.g. Sunday 27 September, 1998)
monthNames = new Array("January","February","March",
"April","May","June",
"July","August","September",
"October","November","December");
dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday");
dayOfWeek = this.getDay();
day = dayNames[dayOfWeek];
dateOfMonth = this.getDate();
monthNo = this.getMonth();
month = monthNames[monthNo];
year = this.getYear();
if (year < 2000)
year = year + 1900;
dateStr = day+" "+dateOfMonth+" "+month+", "+year;
return dateStr;
}
//register the method in the class Date
Date.prototype.getLongDateString=getLongDateString;
function DocDate()
{ //return the document modification date (excl.time)
//as a string
DateTimeStr = document.lastModified;
secOffset = Date.parse(DateTimeStr);
if (secOffset == 0 || secOffset == null) //Opera3.2
dateStr = "Unknown";
else
{
aDate = new Date();
aDate.setTime(secOffset);
//use method defined above
datestr = aDate.getLongDateString();
}
return dateStr;
}
document.write("Last Update: ");
document.writeln(DocDate());
// end hiding script from old browsers -->