...

View Full Version : date doesn't work in Firefox



tpeck
07-27-2006, 05:42 PM
I have a little script which gives the date - actually the year - and updates the copyright portion of the page each year automatically. But it fails in Firefox.

I can't quite see why (well, not at all).

Does anyone know the reason? Here is the external js:

copywrite=new Date();
update=copywrite.getYear();

and in each page at the bottom:

<p align="center">
<span style="color: #C0C0C0; font-family: Arial; font-weight: 700; font-size: 10px; font-style:italic">
Copyright Donald Duck 2004-<script language="JavaScript">document.write(update);</script>&nbsp;&nbsp;All Rights Reserved</span></p>

I guess it'll be obvious but I don't get it.

In IE it renders: Copyright Donald Duck 2004-2006 All Rights Reserved

In FF: Copyright Donald Duck 2004-106 All Rights Reserved

Thanks,

Terry

fishluvr
07-27-2006, 05:56 PM
update=copywrite.getFullYear();

felgall
07-27-2006, 09:06 PM
getYear() works differently in different browsers because of a Y2K bug. To get consistent results you need to use getFullYear() which is the Y2K corrected version of the method. If you only want the last two digits of the year then use substr() to extract what you want after retrieving the full 4 digit version.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum