Search code examples
google-chromeinternet-explorertimezoneutcdygraphs

Different display of Dygraphs data in IE and Chrome


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.


Solution

  • 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.