checks whether the specified date is working or not

boolean isWorkTime(object|Date config);
configobject|Dateeither the configuration object of a time span or a specific date
booleantrue, if the specified date is working time. Otherwise, false


//checks whether the specified date is a working day in global settings
gantt.isWorkTime({ date: new Date(2023,3,5) });
// or
gantt.isWorkTime(new Date(2023,3,5));
//checks whether the specified date is working day for a specific task
gantt.isWorkTime({date: new Date(2023,3,5), task: task});


If the work_time option is disabled, the method always returns true.

Let's assume that you set the following working time for the chart:

  • Working days: Monday - Friday
  • Working hours: 6:00 - 15:00

Then, if you check Monday April,3 2023 as in, you will get:

gantt.isWorkTime({date: new Date(2023,3,3,17,00), unit: "hour"}); 
//->false, cause 17:00-18:00 is not working time
gantt.isWorkTime({date: new Date(2023,3,3,17,00), unit:  "day"}); 
//-> true, cause Monday is a working day

Configuration object properties

The configuration object can contain the following properties:

  • date - (Date) a date to check
  • unit - (string) optional, a time unit: "minute", "hour", "day", "week", "month", "year"
  • task - (object) optional, the object of the task the duration of which should be calculated
if (gantt.isWorkTime({date: date, task: task})){
    alert("worktime of task" + task.text);
See also
Back to top