0

I'm using Dygraph to show nice graphs of my data. My data has the following structure:

data = [[new Date(\"2015-10-08T11:23:44.712\"),0.01,0.06,0.02],[new Date etc.

This data is supposed to display UTC time, so in the above example it's 11:23. I am living in the Netherlands, where it's UTC +2 in summer time, so the local time is 13:23.

When I check my Dygraph with this data in Chrome, it displays 13:23. However, when I open the same data/graph in Internet Explorer (9, 10 or 11), it displays 11:23 instead of 13:23. It seems to display UTC, not the local.

I have tried to find an answer, but am so far unable to find the reason for the different behavior per browser. To be clear: the data supplied to the graph is always the same, the display is not.

http://dygraphs.com/tests/labelsDateUTC.html was a nice example of UTC display. However, setting labelsUTC to either true or false does not change the display of the time in Chrome, nor IE.

I hope someone can point me in the right direction.

Tjab
  • 368
  • 1
  • 4
  • 18
  • Slightly different context in the dup question than yours, but the accepted answer is the same, and explains your observations. – Matt Johnson-Pint Oct 09 '15 at 17:16
  • Thanks, very clear answer in the post. I don't seem to understand why Chrome sees the date as UTC and converts it to local, where as IE sees it as ?? and does not convert but simply shows it. `2015-10-12T07:05:00.000` shows as `07:05` in IE and as `09:05` in Chrome, where as `2015-10-12T07:05:00.000Z` shows as `09:05` in all browsers. – Tjab Oct 12 '15 at 07:08

1 Answers1

0

Ok, it might be that I'm just an idiot and that this is why I couldn't find the answer to my problem. Anyway, it seems to be solved. I was playing around with the data string, removing the new Date part (didn't work, broke everything), but then I added the Z and now it does work.

So basically, data should be:

[new Date("2015-10-08T11:23:44.712Z"),0.01,0.06,0.02]

Instead of

[new Date("2015-10-08T11:23:44.712"),0.01,0.06,0.02]

Notice the absence of the Z in the wrongful version. I find it interesting that Chrome doesn't need the Z and IE does, but well.

Tjab
  • 368
  • 1
  • 4
  • 18