How can I update baselines?

I’m trying to update my baselines as follows

    updateBaselines(tasks, activities) {
        for (let i = 0; i < activities.length; i++) {
            var act = tasks.find(x => x.activityId === activities[i].activityId);
            if (act !== undefined) {
                var activity = gantt.getTask(act.id);
                activity.planned_start = gantt.date.parseDate(new Date(activities[i].plannedStartDate), "xml_date"); 
                //activities[i].plannedStartDate ="2018-02-15T08:00:00+00:00" string value
              
                  //same scenario with this planned_end value.
                 activity.planned_end = gantt.date.parseDate(new Date(activities[i].plannedEndDate), "xml_date");

                //the dates are correct when checking activity
                gantt.updateTask(activity.id);
               
               //after updateTask is called both planned_start and planned_end are set to date objects of 
               ///Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time) {}
            }
        }
        gantt.refreshData();
    }

Why are the dates reverting toa date of
Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time) {}
after calling updateTask?

THis only happens when I update a task, not create one.

Hi,

gantt.date.parseDate(new Date(activities[i].plannedEndDate), "xml_date");

parseDate ( date, format)

Please note date parameter should be a string.
docs.dhtmlx.com/gantt/api__gant … other.html

Format parameter is specifying the format for dates using any character from the following list.

If you clarify this date “activities[i].plannedStartDate” and what you try to achieve as a result, possibly I could help you.

Thanks for replying.

The value of activities[i].plannedStartDate is a string value of the date that looks like this “2018-02-15T08:00:00+00:00”

I replaced gantt.parrseDate() method with new Date() it seems to work fine now. Thanks for your help.