0

I'm using ASP.NET MVC 3 with the default Json serializer (not Json.NET implemented in MVC4+) and dates from my JsonResults come back looking like /Date(-105998400000)/. I am parsing the number out and newing up a Date with this value, but I get inconsistent results between IE and Chrome.

var date = new Date(-105998400000);

See my jsfiddle in various browsers. My results are:

IE10 - Mon Aug 22 23:00:00 EST 1966
Firefox - Tue Aug 23 1966 00:00:00 GMT-0400 (US Eastern Standard Time)
Chrome - Tue Aug 23 1966 00:00:00 GMT-0400 (US Eastern Daylight Time)

Two of my clients are seeing the August 22 date in Chrome.

Why does a new Date return different values in different browsers with the UTC milliseconds value?

PancakeParfait
  • 175
  • 1
  • 9
  • it has to do with the timezone, dates are displayed in local format, but new Date(n) takes a GMT date. are the two clients seeing the 22nd from west of the ones seeing the 23rd? – dandavis Aug 11 '14 at 18:50
  • fwiw, i get the same results in IE (10, 9 as 10) as i do in Chrome. – dandavis Aug 11 '14 at 18:59
  • I think you may be right that this is a time zone issue. Until 2006, Indiana did not observe DST. If there is some kind of conversion to UTC then back and one time zone is wrong, perhaps that would account for the one hour difference? Notice that only my Firefox and Chrome results explicitly note the GMT offset in the output string. – PancakeParfait Aug 11 '14 at 19:12
  • 1
    you don't need to wonder, that's exactly what it is. 11pm on the 22nd in chicago is the exact same moment as midnite on the 23rd in NYC. i'm not sure how browsers map past dates to timezones or handle weird locales like Indiana (which i live close to and it has always confused us), but the issue is cosmetic because the actual dates are all reporting the same moment in all browsers. – dandavis Aug 11 '14 at 19:15
  • @PancakeParfait DST might be the issue because IE is returning the time 1 hour backward. – Derek 朕會功夫 Aug 11 '14 at 19:15

1 Answers1

0

My original implemented answer to this issue is here, using ISO 8601 dates from the Json.NET serializer instead of UTC millisecond offsets from the legacy ASP.NET MVC3 Json serializer.

I did get some insight with this odd outcome thanks to user dandavis.

Community
  • 1
  • 1
PancakeParfait
  • 175
  • 1
  • 9