getSubtaskDates

calculates the combined start/end dates of tasks nested in a project or another task

object getSubtaskDates( [string | number task_id] );
task_idstring | numberthe task's id, root_id will be used if not specified
objectan object containing the start_date and end_date properties

Example

// duration of the whole project
let dates = gantt.getSubtaskDates();
const dateToStr = gantt.templates.task_date;
 
console.log(`${dateToStr(dates.start_date)} - ${dateToStr(dates.end_date)}`);
 
// duration of the subproject
dates = gantt.getSubtaskDates(1);
 
console.log(`${dateToStr(dates.start_date)} - ${dateToStr(dates.end_date)}`);

Details

The method returns an object containing the start date of the earliest subtask and the end date of the latest subtask.

The return object has the following format:

{
  start_date: Date|null,
  end_date: Date|null
}

If a Gantt chart has any scheduled tasks, both properties will have date values. If the Gantt chart is empty or contains only unscheduled tasks, both properties will have null values.

See also
Back to top