When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Friday, January 14, 2000

Netscape vs. IE Date Glitch

By TJ Sylvester

Many people have noticed a potential glitch in Netscape Communicator which will display the year 2000 as 100. Both Netscape and Internet Explorer have returned two digits as the year returned, until this year.

- continued -

Using the getYear() method, the date will appear as 19100 for Netscape Communicator or 192000 for Internet Explorer, because the 19 is hard coded static text.

The method getYear() in JavaScript will return only the year of the current date. In Internet Explorer, the year is returned as 2000. In Netscape the year is returned as 100. Netscape has released technical articles on the specifics of this glitch at:

  • http://developer.netscape.com:80/viewsource/goodman_2k.html
  • http://developer.netscape.com:80/viewsource/wyner_2k/wyner_2k.html

    According to Netscape, a new method getFullYear() will return the entire year. Netscape urges programmers to use this method as a way to maintain backward compatibility. No big deal, except many programmers were not aware of this additional method. In addition, there is no explanation why Internet Explorer returns the date as 2000, while still displaying two digits for the years beforehand.

    No matter how you look at it, both browser makers have potential problems with the way the year is returned.

    Emery Jeffreys, of Bytewriter, recently wrote an article to inform programmers of potential problems. If it were not for this article, I would still believe this to be a bug in Netscape. As a programmer, I have never been advised by Netscape to use the getFullYear() method. I am happy to be a graphic artist and stick to VBScript.

    The following is a breakdown of how each browser interprets the date with each method.

    Netscape Communicator
     December 31, 1999January 1, 2000

    Internet Explorer
     December 31, 1999January 1, 2000

    The following is a description of the code used by many websites to display the date on a web page. View the following with both browsers to see the results. The following JavaScript code:

    <script LANGUAGE="JavaScript"> <!-- Begin mydate = ""; myyear = ""; mydate = new Date(); myyear= mydate.getYear(); document.write("Today's date is:<br>"); document.write(mydate); // End --> </script>

    will produce the following results:

    Using this JavaScript code, (note: the 19 is hard coded, static text; this approach may have been used by developers who wanted the GetYear() method to return a four digit date...)

    <script LANGUAGE="JavaScript"> <!-- Begin mydate = ""; myyear = ""; mydate = new Date(); myyear= mydate.getYear(); document.write("The year is:<br>"); document.write("19" + myyear); // End --> </script>

    will produce the following results:

    Happy Programming!

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article