Reputation: 981
I have a basic gantt chart set up with an array of projects with each task that looks like this:
{
text: "test title"
start_date: "2020-03-21"
end_date: "2020-03-27"
projectNumber: "3525"
id: 95
}
I have my date_format set like this:
gantt.config.date_format = '%Y-%m-%d';
The data loads fine and the chart gets populated with the data but when I go to get a task by Id or show all chart tasks, the output shows the dates as objects and not as strings like I originally set them. This is an example output:
text: "test"
start_date: Sat Mar 21 2020 00:00:00 GMT-0400 (Eastern Daylight Time) {}
end_date: Fri Mar 27 2020 00:00:00 GMT-0400 (Eastern Daylight Time) {}
projectNumber: "48"
id: 9
progress: 0
$no_start: false
$no_end: false
$rendered_type: "task"
duration: 6
$source: []
$target: []
parent: 0
$rendered_parent: 0
$level: 0
$open: false
$index: 0
Why aren't the start and end dates strings in the same format that I inserted them as? Is this default behavior of the gantt chart?
Upvotes: 0
Views: 404
Reputation: 616
Yes, it is by design. Gantt works directly with the date objects. If you want to save the data in a JSON variable, you can use the gantt.serialize()
method, and the dates will be converted to strings:
https://docs.dhtmlx.com/gantt/api__gantt_serialize.html
Upvotes: 1