Skip to main content

date_format

Description

Sets the date format that is used to parse data from a data set and to send dates back to the server

date_format: string

Example

gantt.config.date_format = "%Y-%m-%d %H:%i";
...
gantt.init("gantt_here");
gantt.load("/data/tasks");

Default value: "%d-%m-%Y %H:%i"

Details

This config value is used to generate parse_date and format_date template functions. If you want to use a custom format, you can either change this config, or redefine parse_date and format_date templates directly.

Loading dates in ISO format

Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. The date_format config is not needed for ISO strings - they are recognized and parsed directly.

When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the DataProcessor. Date-only strings (e.g., "2026-01-06") are serialized back as date-only strings, preserving the original format.

The date_format config still applies to non-ISO date strings.

Gantt v9.1.2 and earlier

In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override parse_date and format_date templates to handle ISO strings:

gantt.templates.parse_date = function(date) {
return new Date(date);
};
gantt.templates.format_date = function(date) {
return date.toISOString();
};

For more details, see Loading dates in ISO format.

Changing the date format dynamically

If you need to change the date format dynamically, it is necessary to modify the parse_date template in the following way:

const cfg = gantt.config;
const strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);

gantt.templates.parse_date = function(date){
return strToDate (date);
};
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.