JSON date formats

Hi,

I’m trying to send JSON data to the scheduler. My format looks like:

[ { // ... "start_date": "2015-10-02[b]T[/b]22:15:00", "end_date": "2015-10-02[b]T[/b]22:20:00", // ... }, ... ]

As it turns out the scheduler doesn’t seem to support this format (dates are invalid). I tried to change the
scheduler.config.xml_date = “%Y-%m-%dT%H:%i”;

which allows dates like “start_date”: “2015-10-02 22:15:00”,
but not like “start_date”: “2015-10-02T22:15:00”, (notice the T between the date and the time).

I would like to stick to the standard JSON date format (ISO 8601), how can I do this?

BTW, when sending data to the server this seems to be the format that is used.

Ref article: hanselman.com/blog/OnTheNigh … ebAPI.aspx

TIA for your support,
Gaston

Hi,

UPDATE (2019-09-16)

Starting from v5.2 the scheduler can detect and parse ISO dates automatically and no additional configuration should be needed for that.

Although, you’ll still need a config in order to use the ISO format for the updated dates that are sent to the backend:

scheduler.attachEvent("onTemplatesReady", function(){
  scheduler.templates.format_date = function(date){
    return date.toISOString();
  };
});

Demo: https://snippet.dhtmlx.com/c7fafdfa3 (drag and drop any task to see the date format)

Old reply:

currently the only way is to redefine functions that does formatting and parsing of date strings, here is the example:
docs.dhtmlx.com/scheduler/snippet/17b8c388