setWorkTime is invalid

Hello,
I has set the workTime, but the start_date and the end_date are four minutes longer than I set.

This is my config:

gantt.setWorkTime({ hours: [‘9:00-17:00’] }) //global working hours
gantt.config.duration_unit = ‘hour’

Please check the demo
https://snippet.dhtmlx.com/bwv8rs7p

In my project, after the drag is over, the time becomes 16:00, but my working hours are 09:00-17:00.
Look at this GIF

ggg

The start time and end time should be 09:00 and 17:00.
The start time should be 2024-08-29 09:00:00 The end time should be 2024-08-30 17:00:00.

Is there any configuration?
Is there any configuration that allows the start time of the working time to be 09:00 and the end time to be 17:00 after the end of the drag and drop?

My configuration is the same as the link above

Hello Menglin,
After you finish dragging the task, Gantt snaps the task to the nearest cell which is 16:00.
The setWorkTime method only specifies the working hours. It means that the duration outside the working hours is not included. It doesn’t correct the task position on drag.
So, if the task duration is 8 hours and the task starts at 16:00, it is 1 working hour for the current day and 7 working hours for the following day. So, the task ends 16:00 the next day. There is nothing wrong with that in Gantt.

I see that in the snippet, the tasks appear to start from 09:04, and it looks as if it is a bug in Gantt. But the cause of the issue is the wrong Gantt configuration.
First, the date format is not correct. You set the format to %Y-%d-%m %H:%m:%s, but the task dates have this format: %m-%d-%Y. So, if you disable auto-scheduling, the dates will be in 190X year - and that reveals the wrong date format.
Second, the %m means month only. But you are trying to use it both as the month and as minutes:

%Y-%d-%m %H:%m:%s

The correct value for minutes is %i:

%Y-%d-%m %H:%i:%s

https://docs.dhtmlx.com/gantt/desktop__date_format.html#:~:text=the%20minute%20as%20a%20number%20with%20a%20leading%20zero

There is no built-in way to snap the dates only to the start and end of the working time. You need to implement a custom solution by using the Gantt API and Javascript.

Here is an example of how it can be implemented:

And here is the updated snippet:
https://snippet.dhtmlx.com/s9tvnc2c