Automatic date correction

Hello,ramil!
I have a small question to ask if gantt can automatically correct the input date according to the calendar. For example, the start time of my calendar is from 8 am to 16 PM, so when I create a new task, the start time is 2022-12-8 Can you automatically adjust it to 2022-12-08:00 according to the calendar?
Looking forward to your reply.
Thank you!

Hello,
To make Gantt adjust or snap the task dates to the working time, you need to enable the correct_work_time config:
https://docs.dhtmlx.com/gantt/api__gantt_correct_work_time_config.html

But that is not enough. If you enable the work_time config, for the “day” duration_unit, the duration is calculated in days, and the days start at 00:00. So, Gantt won’t move the tasks to 08:00.
You need to change the duration_unit to “hour”:
https://docs.dhtmlx.com/gantt/api__gantt_duration_unit_config.html

Here is an example:
https://snippet.dhtmlx.com/1kgfi5pt

With your help, the problem has been solved.
Thanks again for your help!

1 Like