Forum Moderators: open
try it like this...
var now = new Date();
var yr = now.getUTCFullYear();
alert(yr);
birdbrain
Why is this so?
The getYear() function is meant to return the current year - 1900. So Y2k = 100 and 2001 = 101 etc.
98, 99, 100, 101, 102, 103, ...
M$ in their infinite wisdom decided to break this by returning:
98, 99, 2000, 2001, 2002, 2003, ...
which makes absolutely no sense but was enough to make the function useless.
The 'correct' call is no getFullYear() which returns the full 4-digit year. I've never heard of a UTC version but you live and learn ;)
I've never heard of a UTC version but you live and learn.
Well, I believe that it's been lurking around since NN4 / IE 4 days. ;)
birdbrain