0

Im trying to set a date time using new Date(<dateTime>), but the behaviour is different in chrome and IE/Firefox.

Works fine for IE/Firefox but not for chrome: var date = new Date("2015-08-20T11:54");

Works fine in Chrome but not in IE/Firefox: var date = new Date("2015-08-20 11:54 am");

My questions:

  1. What is the fundamental difference? is Date() implementation different in Chrome, IE/Firefox?
  2. Is there a time format that is accepted by all the browsers when i use new Date()>
Shebin Koshy
  • 1,182
  • 8
  • 22
  • jQuery doesn't have its own implementation of Date()... – BoltClock Sep 02 '15 at 05:44
  • possible duplicate? http://stackoverflow.com/questions/15109894/new-date-works-differently-in-chrome-and-firefox – b0redom Sep 02 '15 at 05:44
  • `var date = new Date("2015-08-20T11:54");` works in chrome, but there is a difference between `new Date("2015-08-20T11:54");` and `new Date("2015-08-20T11:54Z");` (note the trailing Z) in Firefox and IE, but no difference in chrome – Jaromanda X Sep 02 '15 at 05:53
  • Your first example works for me in Chrome: `var date = new Date("2015-08-20T11:54");` It results in `Thu Aug 20 2015 04:54:00 GMT-0700 (Pacific Daylight Time)` – jfriend00 Sep 02 '15 at 05:59
  • If you want to know what all ES5 compatible browsers support, you can read the Date object spec (section 15.9.1.15) here: http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262%205th%20edition%20December%202009.pdf – jfriend00 Sep 02 '15 at 06:00

0 Answers0