PDA

View Full Version : Unable to get the correct document modification date to display using JavaScript


Deb Deppeler
11-05-2003, 04:02 PM
I have inserted the following into my html

<script language="JavaScript">
lastModDate=new Date(document.lastModified);
document.write("Last updated: " + lastModDate) ;
</script>


The results of this show up in the page as:

Last updated: Wed Dec 31 1969 18:00:00 GMT-0600 (Central Standard Time)


I believe that it is the file server that is returning the wrong information for the current document, but am unable to change that.

Has anyone else experienced this and found a work around?

thanks,
-Deb

liorean
11-05-2003, 04:11 PM
Last-Modified may be not present or 0 (both of which makes document.lastModified 0), which would return "Thu Jan 01 1970 01:00:00 GMT+0100" in my case, or "Wed Dec 31 1969 18:00:00 GMT-0600" in your case.

Have a look at your http headers to be sure why it evaluates to 0.

Deb Deppeler
11-05-2003, 04:45 PM
Thanks for the quick response.

Yes, you're right. The Modified date is not being sent by the web page server. I do not have access or permission to control the web server's configuration.

Is there any other way to get this information? Currently, I must edit this information manually for each page that I edit.

thanks,
Deb

liorean
11-05-2003, 04:56 PM
If the server doesn't send it, how about making a serverside script that adds it, and call all pages through that script? SSI could also do it. If both of those options are blocked, however, I believe you have no choice but to add it to each separate file.

Deb Deppeler
11-05-2003, 05:07 PM
My server side scripting ability is minimal, but I can try. I will also try to get our web server managers to change the server config, so that this information is automatically sent.

thanks for you timely responses,
Deb