# date_format

### Description

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

@signature: date_format: string

### Example

~~~jsx
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`](api/template/parse_date.md) and [`format_date`](api/template/format_date.md) 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](api/method/dataprocessor.md). 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.

:::tip 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:

~~~js
gantt.templates.parse_date = (date) => new Date(date);
gantt.templates.format_date = (date) => date.toISOString();
~~~

:::

For more details, see [Loading dates in ISO format](guides/loading.md#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`](api/template/parse_date.md) template in the following way:

~~~js
const config = gantt.config;
const parseDate = gantt.date.str_to_date(config.date_format, config.server_utc);

gantt.templates.parse_date = (date) => parseDate(date);
~~~

### Related API
- [parse_date](api/template/parse_date.md)
- [format_date](api/template/format_date.md)

### Related Guides
- [Date Format Specification](guides/date-format.md)
