0

This code syntax works with Chrome & Safari, but not with Firefox.

I think it could be to do with the date format(dd-mmm-yyyy).

How do I get all 3 browsers to work with this date format?

var weekday = new Date('14-Mar-2018').getDay();

JSFiddle

arnoldtm
  • 77
  • 12
  • 1
    Possible duplicate of [Why does Date.parse give incorrect results?](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results) – CBroe Mar 14 '18 at 15:33
  • According to [W3Schools](https://www.w3schools.com/js/js_date_formats.asp), `The behavior of "DD-MM-YYYY" is also undefined. Some browsers will try to guess the format. Some will return NaN.` – pfg Mar 14 '18 at 15:38
  • Thanks @pfg - Changed format to 'yy-mm-dd' and it works on all browsers. – arnoldtm Mar 14 '18 at 16:12

1 Answers1

0

Changed format to 'yy-mm-dd', as 'dd-mm-yy' was undefined on Firefox

arnoldtm
  • 77
  • 12