parse_date

converts date string into a Date object

datestringthe string which need to be parsed

Example

var cfg = gantt.config;
var strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
 
gantt.templates.parse_date = function(date){
    return strToDate (date);
};

Details

This function is called from gantt.load() or gantt.parse() call to parse the start_date/end_date properties of tasks, if they are provided in the string format. This function can be redefined if you use a custom format that the default method can't parse. Check Date Format Specification.

Read more about date objects.

Loading dates in ISO format

You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:

gantt.templates.parse_date = function(date) { 
    return new Date(date);
};
gantt.templates.format_date = function(date) { 
    return date.toISOString();
};
See also
Back to top