Michael Brown June 21 2010 04:09:19 AMThis is is what happens when you design for a monoculture - especially one as godawful as Microsoft's - instead of designing to standards.
var todayVar = new Date; // Initialised to today's date
on today's date, 21st June 2010, it should return the number "110". And on any browser other than IE, that's exactly what it does. IE on the other hand, returns the full, four-digit year, "2010"; that's on all versions of IE, up to and including version 8.
Why is this a problem? Well, it's not if all you're ever planning to use is IE. And if that describes you, then you seriously need shooting. The problem occurs, of course, if you use any browser other than IE. For example, I've just seen an application that relied on getYear() returning a four-digit date to do its thing. The developer had seen getYear() do that in IE and simply assumed that's what the function is supposed to do rather than looking the function up. The end result was that IE appeared to be the only browser that worked correctly, whereas other browsers produced screwy results.
If that developer had tested with just one other browser, he'd have spotted his mistake and rectified it. The correct function to use, by the way, is getFullYear(), which returns a four-digit year on any browser.
- Comments