1

I am trying to parse date with formate like '00/09/2000' in IE.

IE or Edge:

enter image description here

We can see that the output is a date of Dec 09 1998. However, in browser other than IE, this will throw error saying invalid date.

Chrome:

enter image description here

My question is, how can we disable the behavior on IE?

Junbang Huang
  • 1,927
  • 19
  • 26
  • Just a note, date formats other than YYY-MM-DD are browser dependent anyway.. For working with date's / time's, what I would suggest is using a library like moment.js. – Keith Aug 23 '17 at 21:37
  • You can't disable this behavior. –  Aug 23 '17 at 22:02
  • you probably want to place 00 with 12 whenever the date data comes in. – Charlie Ng Aug 23 '17 at 22:12
  • Can you share/provide more information about where you get the date `00/09/2000`? – Mauricio Arias Olave Aug 23 '17 at 22:32
  • @MauricioAriasOlave you pretty much have all the info. I am using format like MM/DD/YYYY and someone inputs 00/09/2000 – Junbang Huang Aug 23 '17 at 22:33
  • @JunbangHuang I don't know if is a good approach, but, since you said is in `MM/DD/YYYY` format, I should split the result and build a new Date instance, adding +1 to Month. – Mauricio Arias Olave Aug 23 '17 at 22:39
  • How to disable it? Every time a programmer writes code that uses the built-in parser, dock their pay 10%. – RobG Aug 23 '17 at 22:39
  • @RobG not quiet sure how is this one is duplicated – Junbang Huang Aug 23 '17 at 22:42
  • The duplicate explains that parsing of any format other than that defined in ECMA-262 is implementation dependent, the only fix for that is to not use the built-in parser. – RobG Aug 23 '17 at 23:04

0 Answers0