W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 2000

problem with lastModified

From: Work, Jason <Jason.Work@BCHydro.bc.ca>
Date: Fri, 7 Jan 2000 12:18:08 -0500 (EST)
Message-ID: <F31B8E63892ED311A8DB0000F81A9700DB4E82@edmm61.bchydro.bc.ca>
To: "'www-jigsaw@w3.org'" <www-jigsaw@w3.org>
Hello.

It seems that the whole Y2K thing has had an effect on javascript.  Here is
my problem.

I wish to post a last modified on my page.  It should read, "This page was
last modified on Jan 7, 2000.  There are two problems with this.

The first problem lies in the fact that the date is set back to 0.  Can this
be remedied with a  simple (y==y:2000+y:y)?  

The second problem is that the date from the call, document.lastModified
displays a time that is incorrect.  It shows a time that is exactly eight
hours ahead.  I am in the Pacific Time Zone that happens to be eight hours
ahead of Grenwich mean time.  How can I change the time so that it reflects
the correct time here?

The code for a simple lastModified is as follows:

<html><head><body><script language="JavaScript"><!-- Begin

document.write('<center>Last updated : ');
document.write(document.lastModified);
document.write('</center>');

// End --></script></p></body></html>

The date on this code is affected by the eight hour gap too.   Why is this
and how can it be changed for it to work properly in Vancouver?

<script language="JavaScript">
<!-- 
//
//
function date_ddmmmyyyy(date)
{
  var d = date.getDate();
  var m = date.getMonth() + 1;
  var y = date.getYear();

  // could use splitString() here 
  // but the following method is 
  // more compatible
  var mmm = 
    ( 1==m)?'Jan':( 2==m)?'Feb':(3==m)?'Mar':
    ( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
    ( 7==m)?'Jul':( 8==m)?'Aug':(9==m)?'Sep':
    (10==m)?'Oct':(11==m)?'Nov':'Dec';

  return "" +
    mmm + " " +
    d + ", " +
    (y==y?2000+y:y);
}


//
// get last modified date of the 
// current document.
//
function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = "" + date_ddmmmyyyy(new Date(d1));
  }

  return s;
}

//
//
document.write( 
  "This page was updated on " + 
  date_lastmodified() );

// -->
</script>


Thank you.  Please reply to my e-mail address.

Regards,

Jason
Received on Friday, 7 January 2000 12:25:56 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:34 GMT