Revison Date/Time in Java Script

Christopher Locke clocke at panix.com
Tue Jun 24 13:43:34 EDT 1997


At 12:08 PM 6/24/97 -0700, Sam A. Khosh-Khui 512/245-2288 wrote:
>        I have a problem with displaying the correct time/date in a Java 
>        script.  I would appreciate it if someone out there would offer a 
>        solution.  

the datestamp defaults to GMT, but there's a way to adjust for
that using the Date.toLocaleString() method. you'll have to work
out the details, as I haven't ever done this.  the best book
I've found on the subject is David Flanagan's _Javascript: The
Definitive Guide_.  For a limited time, O'Reilly & Asoociates
have made this entire book available online at:

   http://www.ora.com/books/webref/jscript/index.htm

however, there's a larger issue: this *does not work at all*
when the page is accessed with Microsoft's Internet Explorer --
at least up to 4.0, and I'm not sure about the latter.  

I wanted to use the same technique to replace Server Side
Includes, which is how I datestamp the pages I maintain at
http://www.displaytech.com so I was quite bummed to discover
MSIE couldn't parse this nifty bit of JS code.  the SSI trick
works fine, but entails a non-trivial performance hit on the server.  

for specific info on SSI, see the terrific CGI book (again by
O'Reilly & Associates) at:

   http://www.ora.com/info/cgi/ch05.html

hope this is useful

chris

At 12:08 PM 6/24/97 -0700, Sam A. Khosh-Khui 512/245-2288 wrote:
>        I have a problem with displaying the correct time/date in a Java 
>        script.  I would appreciate it if someone out there would offer a 
>        solution.  Here is the problem.
>        
>        I use the following Java script in an html file to display the 
>        revision date:
>        
>            <SCRIPT LANGUAGE="JavaScript">
>            <!--hide script from old browsers
>            document.write("Last Updated: " + document.lastModified);
>            // end hiding -->
>            </script>
>            
>        I revised and saved the file on June 19th, 1997, at 1:54 p.m. 
>        CST.  However, when I reload the file and viewed it in Netscape, 
>        the revision date/time listed as:
>        
>            Jun 19 18:54:00 1997 
>            
>        I don't know how this 5 hour difference was added to the revision 
>        date.
>        
>        1)  How do I eliminate the time element in revision date?
>        2)  How do I display the correct date/time?
>        3)  How do I reformat the existing revision date to: 6/19/97 or 
>            June 19, 1997?
>            
>        Thanks in advance,
>        
>        Sam A. Khosh-khui
>        E-mail: sk03 at swt.edu
>        Alkek Library
>        Southwest Texas State University
>        
>        
>        
>
>


More information about the Web4lib mailing list