homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

"Page last Updated" JavaScript
Opera Browser has wrong date

10+ Year Member

Msg#: 4876 posted 3:20 am on Jan 19, 2006 (gmt 0)

All the other browsers post the correct date. The Opera browser post the Last update as 07/31/1969. The script is below. How can this be corrected?
Thanks in Advance

<script language="Javascript">
document.write("The page that contains this example was last updated on: "+document.lastModified+"")


JAB Creations

WebmasterWorld Senior Member jab_creations us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4876 posted 12:09 am on Jan 20, 2006 (gmt 0)

Hi SenMar,

Does the page with the error use any serverside scripting? If so then JavaScript will (correctly) send the time the file was rendered.

The solution is to use the serverside language you're using to achieve this instead, though I'm not sure what language that is.

Let me know what language and I'll try to help you out.



10+ Year Member

Msg#: 4876 posted 8:01 pm on Jan 20, 2006 (gmt 0)

The document.lastModified item is part of a group of which some of the items can be used for attacking the server. Some ISP's simply ban the entire group rather than blocking the individual bad items. When that is done, the document.lastModified is returned as a null value.

Internet Explorer takes the null value, uses it as-is in the "new Date()" function, and gets back the CURRENT date and time. This makes it appear that the page was updated just seconds ago. If you don't look too closely, this seems to be correct, and you're happy with what you see.

Netscape takes the null value, forces it to numeric, gets a zero at this point, uses that zero in the "new Date()" function, and gets back the first midnight of January 1st in 1970. It then applies the timezone offset value to give a proper answer based on the user's machine. For me, in the eastern USA, this displays as 7:00pm on December 31 of 1969.

WebTV functions similarly to Netscape, but does the timezone offset earlier in the procedure. This results in a negative value to the "new Date()" function and causes an error.

I've not checked Opera, but it seems to be following the Netscape pattern.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved