I have set my system time to UTC.
IE 10
new Date("2014-06-07T19:00:00")
//Sat Jun 7 19:00:00 UTC+0100 2014
Chrome 35
new Date("2014-06-07T19:00:00")
//Sat Jun 07 2014 20:00:00 GMT+0100 (GMT Daylight Time)
Why is the result different by 1 hour? The date constructor is part of the specification so it should be standard across browsers?
http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.3.2
http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15
The value of an absent time zone offset is “Z”.
(I have figured out how to fix the problem - appending the timezone 'Z' - "2014-06-07T19:00:00Z" produces consistent results, but I am interested in why this is happening in the first place)
Edit:
@Dark Falcon yes, toISOString produces different results for the first string below
<p id=container></p>
container.innerHTML =
new Date("2014-06-07T19:00:00").toISOString() +
'<br>' +
new Date("2014-01-07T19:00:00").toISOString() +
'<br>'+
new Date("2014-06-07T19:00:00Z").toISOString();
IE
2014-06-07T18:00:00.000Z
2014-01-07T19:00:00.000Z
2014-06-07T19:00:00.000Z
Chrome
2014-06-07T19:00:00.000Z
2014-01-07T19:00:00.000Z
2014-06-07T19:00:00.000Z
Edit:
Not sure this is a duplicate of new Date() works differently in Chrome and Firefox , I am not asking how to fix the problem, I am asking why is there a difference in the first place. The accepted answer to that question says 'your input is wrong'. The second answer says 'the spec is imprecise'. I don't think either are correct - note my quote from the spec "The value of an absent time zone offset is “Z”.