View Full Version : date doesn't work in Firefox

07-27-2006, 06: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();

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



07-27-2006, 06:56 PM

07-27-2006, 10: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.