Javascript data parsing in IE vs other browsers... It seems kinda screwed up. What's the deal?

Posted by Carter on Stack Overflow See other posts from Stack Overflow or by Carter
Published on 2010-03-17T21:31:53Z Indexed on 2010/03/17 21:41 UTC
Read the original article Hit count: 215

Firstly, when I say other browsers I really only mean Firefox because that's all I tested in.

Internet Explorer can parse a date followed by a single character as a proper date. Whereas Firefox behaves as I'd expect.

For example...

var dateString = new Date("1/1/2010f");
alert(dateString);

In IE it will alert...

Thu Dec 31 21:00:00 UTC-0900 2009

Whereas in FF is will spit out...

"Invalid Date"

I first noticed this using the jquery validation plug in.

http://docs.jquery.com/Plugins/Validation/Methods/date

It seems like it just subtracts some amount of hours off the actual date in IE when a character is appended. I've tested in IE6 and IE8.

Am I missing something?

© Stack Overflow or respective owner

Related posts about internet-explorer

Related posts about JavaScript