I’m trying to parse tasks with a date in string format like 01-JAN-2018, using this code:
var targetDate = vWOlist[i].targetdate; // has string like 01-JAN-2018
var formatFunc = gantt.date.str_to_date("%d-%M-%Y");
var StartDate = formatFunc(targetDate);
It breaks/is not working, without a clear error. After trying to debug it, I’ve changed the locale_nl file month_shorts to upper case so JAN instead of Jan, but that didn’t help either. Need a little help please. Thank you.
Thanks for the response, I see what’s happening now. I have 2 sets of start and end dates in 2 different formats, guess that’s not possible to parse to date objects? Because I had set gantt.config.xml_date to format 1 and then the formatFunc wasn’t working. But when setting the xml_date to format 2, it was working but the other date fields gave an error.
Hello Maurice,
Yes, it is not possible to have dates in different formats. You need to convert all dates to one format.
You can convert the data to the Date object before parsing it: https://snippet.dhtmlx.com/1bdb6362d
It is not necessary to use gantt.config.xml_date to convert strings to Date objects: