|
|
Q301 Does setYear work correctly if it is given a two-digit year?
irt.org | Knowledge Base | JavaScript | Date | Q301 [ previous next ] Q301 Does setYear work correctly if it is given a two-digit year?Always use four digit dates, that way you are avoiding any potential millennium bugs in your code. Especially when accepting dates from user input. setYear() will accept dates in two digit and four digit format, although it assumes that any two digit dates are for the 20th century, so that:
Whereas:
Note, in Netscape Navigator 2 you cannot use dates less than year dot. Year dot in JavaScript is Midnight January 1st 1970, i.e. the reference point. All dates are represented internally in JavaScript as the number of milliseconds since year dot. Netscape Navigator 2 does not allow negative millisconds, whereas Netscape Navigator 3, Netscape Navigator 4, Internet Explorer 4 and possibly Internet Explorer 3 do. Therefore the following should not be done in Netscape Navigator 2, at best it'll crash the browser, at worse it'll crash the browser, and any other Netscape browser running, plus maybe the odd text editor running, and also any news and or mail programs that are Netscape products - BE WARNED.
However the following all work in Netscape Navigator 3, Netscape Navigator 4 and Internet Explorer 4:
|
-- div -->
|