homepage Welcome to WebmasterWorld Guest from 54.235.16.159
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
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
Senmar50




msg:1473849
 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
SenMar

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

 

JAB Creations




msg:1473850
 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.

John

jalarie




msg:1473851
 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