Ok, so QA gave me this error, where if the date had a single character starting with a month, day or year (date in MM / dd / yyyy format), then (ONLY in IE) it will parse the date, but change it. So, dig and, of course, its VERY weird.
This is an example of the code I'm talking about in IE
$("#dates").append("<li>04/30/2012 = " + new Date("04/30/2012").toString()+"</li>"); $("#dates").append("<li>a04/30/2012 = " + new Date("a04/30/2012").toString() +"</li>"); $("#dates").append("<li>b04/30/2012 = " + new Date("b04/30/2012").toString() +"</li>"); $("#dates").append("<li>c04/30/2012 = " + new Date("c04/30/2012").toString() +"</li>"); $("#dates").append("<li>d04/30/2012 = " + new Date("d04/30/2012").toString() +"</li>"); $("#dates").append("<li>e04/30/2012 = " + new Date("e04/30/2012").toString() +"</li>"); $("#dates").append("<li>04/a30/2012 = " + new Date("04/a30/2012").toString() +"</li>"); $("#dates").append("<li>04/b30/2012 = " + new Date("04/b30/2012").toString() +"</li>"); $("#dates").append("<li>04/c30/2012 = " + new Date("04/c30/2012").toString() +"</li>"); $("#dates").append("<li>04/d30/2012 = " + new Date("04/d30/2012").toString() +"</li>"); $("#dates").append("<li>04/e30/2012 = " + new Date("04/e30/2012").toString() +"</li>"); $("#dates").append("<li>04/30/a2012 = " + new Date("04/30/a2012").toString() +"</li>"); $("#dates").append("<li>04/30/b2012 = " + new Date("04/30/b2012").toString() +"</li>"); $("#dates").append("<li>04/30/c2012 = " + new Date("04/30/c2012").toString() +"</li>"); $("#dates").append("<li>04/30/d2012 = " + new Date("04/30/d2012").toString() +"</li>"); $("#dates").append("<li>04/30/e2012 = " + new Date("04/30/e2012").toString() +"</li>");
And here is what IE displays
•04/30/2012 = Mon Apr 30 2012 00:00:00 GMT-0500 (Central Daylight Time) •a04/30/2012 = Sun Apr 29 2012 20:00:00 GMT-0500 (Central Daylight Time) •b04/30/2012 = Sun Apr 29 2012 21:00:00 GMT-0500 (Central Daylight Time) •c04/30/2012 = Sun Apr 29 2012 22:00:00 GMT-0500 (Central Daylight Time) •d04/30/2012 = Sun Apr 29 2012 23:00:00 GMT-0500 (Central Daylight Time) •e04/30/2012 = Mon Apr 30 2012 00:00:00 GMT-0500 (Central Daylight Time) •04/a30/2012 = Fri Apr 29 -2012 20:00:00 GMT-0500 (Central Daylight Time) •04/b30/2012 = Fri Apr 29 -2012 21:00:00 GMT-0500 (Central Daylight Time) •04/c30/2012 = Fri Apr 29 -2012 22:00:00 GMT-0500 (Central Daylight Time) •04/d30/2012 = Fri Apr 29 -2012 23:00:00 GMT-0500 (Central Daylight Time) •04/e30/2012 = Sat Apr 30 -2012 00:00:00 GMT-0500 (Central Daylight Time) •04/30/a2012 = Sun Apr 29 2012 20:00:00 GMT-0500 (Central Daylight Time) •04/30/b2012 = Sun Apr 29 2012 21:00:00 GMT-0500 (Central Daylight Time) •04/30/c2012 = Sun Apr 29 2012 22:00:00 GMT-0500 (Central Daylight Time) •04/30/d2012 = Sun Apr 29 2012 23:00:00 GMT-0500 (Central Daylight Time) •04/30/e2012 = Mon Apr 30 2012 00:00:00 GMT-0500 (Central Daylight Time)
There is some strange hour, things are added, except when you add a character to the day part of the format, then it flips the year to BC (from 2012 to -2012 ???)
We use event pickers, so the likelihood that this will happen is quite limited (but you know, the QA guys are right ;-) ...) So, how did others deal with this unusual behavior? (FYI: I checked the moment, but it takes the date MM / dd / yyyy and just passes it to the browser date parser, so there are no dice there.
javascript internet-explorer datetime
Josh handel
source share