You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/config/date_format.md
+16-5Lines changed: 16 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,24 +30,35 @@ If you want to use a custom format, you can either change this config, or redefi
30
30
31
31
## Loading dates in ISO format
32
32
33
-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
33
+
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.
34
+
35
+
When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the [DataProcessor](guides/server-side.md). Date-only strings (e.g., `"2026-01-06"`) are serialized back as date-only strings, preserving the original format.
36
+
37
+
The `date_format` config still applies to non-ISO date strings.
38
+
39
+
:::tip Gantt v9.1.2 and earlier
40
+
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:
34
41
35
42
~~~js
36
-
gantt.templates.parse_date=function(date) {
43
+
gantt.templates.parse_date=function(date) {
37
44
returnnewDate(date);
38
45
};
39
-
gantt.templates.format_date=function(date) {
46
+
gantt.templates.format_date=function(date) {
40
47
returndate.toISOString();
41
48
};
42
49
~~~
43
50
51
+
:::
52
+
53
+
For more details, see [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
54
+
44
55
## Changing the date format dynamically
45
56
46
57
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:
47
58
48
59
~~~js
49
-
var cfg =gantt.config;
50
-
var strToDate =gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
Converts a string of the specified format to a Date object
200
+
201
+
Converts a date string to a Date object. This method is called during [gantt.load()](api/method/load.md) and [gantt.parse()](api/method/parse.md) to parse task and link date properties.
201
202
202
203
**Parameters**:
203
-
-`date` - (string) - The date string
204
-
-`format` - (string) - The date format (see guides/date-format.md)
204
+
-`date` - (string) - The date string to parse
205
+
-`format` - (string | function, optional) - A date format string (see [Date Format Specification](guides/date-format.md)) or a custom parser function `(dateStr) => Date`
205
206
206
207
**Returns**: Date - The parsed date object
207
208
208
-
**Example**:
209
+
**Parsing logic** (since v9.1.3):
210
+
211
+
1.**ISO 8601 check** - if the string matches an ISO 8601 pattern (e.g. `"2026-01-06"`, `"2026-01-06T10:30:00Z"`), it is parsed directly and `format` is not consulted. If the user has explicitly overridden `gantt.templates.parse_date`, ISO auto-detection is skipped and the user's function handles all parsing.
212
+
2.**`format` argument** - if provided as a string, it is converted to a parser function via `gantt.date.str_to_date(format)`; if provided as a function, it is called directly
213
+
3.**Fallback** - if no `format` is provided, the [parse_date](api/template/parse_date.md) template is used
214
+
215
+
**Examples**:
209
216
~~~js
210
-
var date =gantt.date.parseDate("29/06/2019","%d/%m/%Y"); //-> 29 June, 2019 00:00:00
217
+
// with an explicit format string
218
+
var date =gantt.date.parseDate("29/06/2019", "%d/%m/%Y");
219
+
// -> 29 June, 2019 00:00:00
220
+
221
+
// ISO string - parsed automatically, format is ignored
222
+
var date2 =gantt.date.parseDate("2026-01-06T10:30:00Z");
223
+
// -> 6 January, 2026 10:30:00 UTC
224
+
225
+
// with a custom parser function
226
+
var date3 =gantt.date.parseDate("Jan 6, 2026", function(str) {
Copy file name to clipboardExpand all lines: docs/api/template/format_date.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,17 +34,25 @@ Check [Date Format Specification](guides/date-format.md).
34
34
35
35
## Loading dates in ISO format
36
36
37
-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
37
+
Since v9.1.3, when ISO 8601 dates are detected on input, dates are serialized back as ISO strings automatically - unless you explicitly override this template. If you define a custom `format_date` function, it takes priority and is used for all dates, including ISO.
38
+
39
+
:::tip Gantt v9.1.2 and earlier
40
+
In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override the templates to handle ISO strings:
38
41
39
42
~~~js
40
-
gantt.templates.parse_date=function(date) {
43
+
gantt.templates.parse_date=function(date) {
41
44
returnnewDate(date);
42
45
};
43
-
gantt.templates.format_date=function(date) {
46
+
gantt.templates.format_date=function(date) {
44
47
returndate.toISOString();
45
48
};
46
49
~~~
47
50
51
+
In v9.1.3+, these overrides are unnecessary for ISO dates.
52
+
:::
53
+
54
+
For more details, see [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
55
+
48
56
## Changing the date format dynamically
49
57
50
58
If you need to change the [date format](api/config/date_format.md) dynamically, it is necessary to modify the [parse_date](api/template/parse_date.md) template in the following way:
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.
36
-
This function can be redefined if you use a custom format that the default method can't parse. Check [Date Format Specification](guides/date-format.md).
35
+
This function can be called from **gantt.load()** or **gantt.parse()** call to parse date properties of tasks, if they are provided in the string format.
36
+
37
+
This function can be redefined if you use a custom date format that the default method can't parse. Check [Date Format Specification](guides/date-format.md).
37
38
38
39
[Read more about date objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date).
39
40
40
41
## Loading dates in ISO format
41
42
42
-
You can use ISO date format in Gantt. For this, you need to redefine functions that parse and serialize dates in Gantt:
43
+
Since v9.1.3, Gantt automatically detects and parses ISO 8601 date strings. A manual `parse_date` override is not needed for ISO dates. However, if you do override this template, your function takes priority - ISO auto-detection is skipped and your function handles all date strings.
44
+
45
+
:::tip Gantt v9.1.2 and earlier
46
+
In versions before v9.1.3, ISO dates were not detected automatically. If you are using an older version, you need to override this template to handle ISO strings:
43
47
44
48
~~~js
45
-
gantt.templates.parse_date=function(date) {
49
+
gantt.templates.parse_date=function(date) {
46
50
returnnewDate(date);
47
51
};
48
-
gantt.templates.format_date=function(date) {
52
+
gantt.templates.format_date=function(date) {
49
53
returndate.toISOString();
50
54
};
51
55
~~~
52
56
57
+
In v9.1.3+, these overrides are unnecessary for ISO dates.
58
+
:::
59
+
60
+
For more details, see [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
Copy file name to clipboardExpand all lines: docs/guides/conversion-templates.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,3 +8,7 @@ sidebar_label: "Templates for Date Conversion"
8
8
-[parse_date](api/template/parse_date.md) - converts date string into a Date object
9
9
-[format_date](api/template/format_date.md) - converts a date object to a date string. Used to send data back to the server
10
10
11
+
:::note
12
+
Since v9.1.3, ISO 8601 dates are handled automatically without overriding these templates. See [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
// ISO dates are parsed automatically - no template overrides needed
185
+
~~~
186
+
187
+
When ISO dates are detected on input, they are serialized back as ISO strings automatically when passed to the [DataProcessor](guides/server-side.md). Date-only strings (e.g., `"2026-01-06"`) are serialized back as date-only strings, preserving the original format. If the input contains a mix of date-only and full datetime strings, all dates are serialized as full datetime.
188
+
189
+
:::note
190
+
Date-only strings (e.g., `"2026-01-06"`) are parsed as local midnight when `server_utc` is set to `false` (the default).
191
+
:::
192
+
193
+
:::note
194
+
If you explicitly override `gantt.templates.parse_date` or `gantt.templates.format_date`, your functions take priority over ISO auto-detection and auto-serialization.
195
+
:::
196
+
197
+
:::tip Gantt v9.1.2 and earlier
198
+
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:
In v9.1.3+, these templates are still used as the fallback for **non-ISO** date strings. See [gantt.date.parseDate()](api/other/date.md#parsedatedate-format) for the full parsing pipeline.
211
+
:::
212
+
179
213
## Changing the date format dynamically
180
214
181
215
If you need to change the [date format](api/config/date_format.md) dynamically, it is necessary to modify the [parse_date](api/template/parse_date.md) template in the following way:
Copy file name to clipboardExpand all lines: docs/integrations/ai-tools/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,11 @@ This section collects materials for using AI with DHTMLX Gantt in two ways:
15
15
16
16
If you're using an AI app builder to generate or modify your UI, start here:
17
17
18
-
-[Lovable AI](./lovable-ai/)— integrate DHTMLX [React Gantt](./../react/) into a Lovable-generated app and improve results using prompts, Knowledge Base, and MCP.
18
+
-[Lovable AI](./lovable-ai/)- integrate DHTMLX [React Gantt](./../react/) into a Lovable-generated app and improve results using prompts, Knowledge Base, and MCP.
19
19
20
20
## MCP Server
21
21
22
-
-[DHTMLX MCP Server](./mcp-server/)— connect an AI tool to up-to-date DHTMLX documentation and API reference.
22
+
-[DHTMLX MCP Server](./mcp-server/)- connect an AI tool to up-to-date DHTMLX documentation and API reference.
Copy file name to clipboardExpand all lines: docs/integrations/react/state/jotai.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,13 +246,17 @@ export default function DemoJotai() {
246
246
247
247
Let's configure the Gantt chart's templates which define date formatting and parsing for consistent data handling:
248
248
249
+
:::note
250
+
Since v9.1.3, Gantt automatically detects ISO date strings and these template overrides are no longer needed. They are shown here for compatibility with earlier Gantt versions. See [Loading dates in ISO format](guides/loading.md#loading-dates-in-iso-format).
Copy file name to clipboardExpand all lines: docs/integrations/react/state/mobx.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,13 +235,17 @@ We wrap our component with `observer()` from `mobx-react-lite` to automatically
235
235
236
236
Let's configure the Gantt chart'stemplateswhichdefinedateformattingandparsingforconsistentdatahandling:
237
237
238
+
:::note
239
+
Sincev9.1.3, GanttautomaticallydetectsISOdatestringsandthesetemplateoverridesarenolongerneeded. TheyareshownhereforcompatibilitywithearlierGanttversions. See [LoadingdatesinISOformat](guides/loading.md#loading-dates-in-iso-format).
0 commit comments