Forum Moderators: open

Message Too Old, No Replies

netscape year fix?

         

reuben101

4:18 pm on Nov 28, 2003 (gmt 0)

10+ Year Member



Hey guys,

Please forgive my limited technical vocabulary! I have installed and customized a small javascript calendar and have killed all the bugs but one. The year displays properly in MSIE as 2003 but in Netscape it displays as 103.

my variables:


var year = Calendar.getYear(); // Returns year
var month = Calendar.getMonth(); // Returns month (0-11)
var today = Calendar.getDate(); // Returns day (1-31)
var weekday = Calendar.getDay(); // Returns day (1-31)

I'm missing something really obvious aren't I? :)

PCInk

4:46 pm on Nov 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



103 is the correct value that should be returned. It should return the number of years since 1900.

Simple solution I use is read in the year, then if it is less than 500, add 1900 to the value.

killroy

4:48 pm on Nov 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



var year=(Calendar.getYear()%1900)+1900; // Returns year

should fix it (not solve it)

SN

reuben101

5:16 pm on Nov 28, 2003 (gmt 0)

10+ Year Member



That did the trick. Thanks to both of you for the lesson. :)

dcrombie

5:04 pm on Nov 29, 2003 (gmt 0)



There's also a new function introduced to make the browsers compatible:
getFullYear() returns the year in YYYY format.

Made me think back to some discussions on c.l.javascript all those years ago ;)