I modified this code (a<200, a+1900) so it works on both IE and Firefox, but I'm having problems with Chrome. Some sites display NaN/NaN/NaN, and others show the date consistently. It doesn't seem to depend on who's hosting the sites.

 <script language="Javascript" type="text/javascript"> 
var lastModificationDate = new Date(document.lastModified);
var a = (lastModificationDate.getYear() );
if (a<200) {a=(a+1900);}
document.write('This page was last updated on ' + (lastModificationDate.getMonth()+1) + '/' + lastModificationDate.getDate() +'/' + a + '');
 </script> 
  • It looks like the code didn't go along with the questions, so here it is: <script language="Javascript" type="text/javascript"> var lastModificationDate = new Date(document.lastModified); var a = (lastModificationDate.getYear() ); if (a<200) {a=(a+1900);} document.write('This page was last updated on ' + (lastModificationDate.getMonth()+1) + '/' + lastModificationDate.getDate() +'/' + a + ''); </script> Dena Abramowitz almost 9 years ago

1 answer

1
point

The problem is a known issue with Webkit based browsers - they sensibly return no date if the Last-Modified HTTP header is not available, you need to further adapt your script, see the thread here for some detail:

http://www.google.com/support/forum/p/Chrome/thread?tid=37eb27384de9274c

basically you need to have a way to handle: if the last modified date is available, use it, if not show the current date, or don't show last modified...

Answered almost 9 years ago by Tony Crockford