JRS: In article <vL*******************@news20.bellglobal.com>, dated
Fri, 29 Jul 2005 22:38:53, seen in news:comp.lang.javascript, alu
<no**@none.com> posted :
var nowDate = new Date();
var year = nowDate.getYear();
year returned '105', while in IE, year returned '2005'.
Can you explain?
Mere idiocy on the part of early implementers of javascript, back in the
1900's and not expecting the 2000's.
Since they were accustomed to writing the year with two digits (which is
moderately unambiguous between the 31st year of a century and the last),
they provided a primitive for a two-digit year number and none for a
proper year number. Naturally, they implemented different behaviours
for after the year '99. Some made the next year 0, some 100, some 2000.
My Web page js-date0.htm refers.
Perfectly stupid : it would have been much simpler to give the full year
in the first place, and it can so readily be converted to two digits if
desired either by using %100 or by substringing. I have a routine, BTW,
for determining the full year in browsers that lack the full year
functions - getFY(), in my js-date0.htm.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.