Odd Date Issue - Items Rendered in the Future on ALl Browsers Apart from FireFox

36 views
Skip to first unread message

Jammer Jamski

unread,
Jun 9, 2014, 2:32:04 PM6/9/14
to chap-link...@googlegroups.com
Hi,

I've got an odd situation going on here.  I've got the following JSON being passed to the time line control:

[
  {
    "UserId": 2,
    "ItemId": 3,
    "ItemText": null,
    "ItemDate": "2014-06-09T18:51:37",
    "ItemDateEnd": null,
    "OutcomeScore": null
  },
...
]

This is a simple of array of items that I pass to the control to render.  In Firefox this renders perfectly, no problems whatsoever.  However, Every other browser I've tried it on shows the items +1 hour.  I've tried it in Opera, Chrome and IE9 and they are all showing the same problem apart from Firefox.

Each browser is running exactly the same query and getting exactly the same JSON.  I'm very confused and not even sure where to start looking.

I'm running v2.5.0 of the time line.  I've tried updating to the latest version and the same thing occured so I rolled back to 2.5.0 to get the solved before working on getting the latest version integrated into the page.

Any ideas would be really appreciated.

James.

Jammer Jamski

unread,
Jun 9, 2014, 2:42:29 PM6/9/14
to chap-link...@googlegroups.com
I forgot to mention that the Now line is showing the correct time ...

James.

Jos de Jong

unread,
Jun 10, 2014, 3:44:33 AM6/10/14
to chap-link...@googlegroups.com
First, note that the Timeline of the CHAP Links library does not support strings as Date, you should provided Dates or a timestamp with a Number (note that the successor of the Timeline, vis.js, does support strings as date). Strings as Date work nowadays because most browsers now support creating dates from an ISO date string.

The issue you have is because you provide an ISO Date String without time zone information. Apparently not all browsers have the same default behavior in that case. Enter the following in a JavaScript console in both Firefox and an other browser:

new Date("2014-06-09T18:51:37").toISOString() // output is ambiguous, time zone information missing

and you will see them adding timezone information in different ways. To prevent these kind of ambiguities, you should provide timezone information yourself. To specify the time in UTC, add a Z to the end of the string:

new Date("2014-06-09T18:51:37Z").toISOString()  // output is unambiguous
Reply all
Reply to author
Forward
0 new messages