Hello,
Is there any methods to formate the time by 2024-01-01 to 2024-01-01 08:00:00 when my workTime is 08:00-17:00
Also, is my workTIme is 09:00-18:00,how to make the time by 2024-01-01 to 2024-01-01 09:00:00.
@Support1
@Alexsander_Silva
@ArtyomBorisevich
Hello Menglin,
If the task date is 2024-01-01
it means that it is 2024-01-01 00:00:00
. So, you cannot format the date. You need to completely change it.
There are different ways to do that, but if you only want to change the dates to the working time when you load the data, you can enable the correct_work_time
config:
https://docs.dhtmlx.com/gantt/api__gantt_correct_work_time_config.html
This will work if the duration_unit
is set to hour
or minute
:
https://docs.dhtmlx.com/gantt/api__gantt_duration_unit_config.html
Otherwise, Gantt will think that any hour is working for the day if it is not a weekend (or at least has 1 working minute during the whole day).
Here is an example in the snippet:
https://snippet.dhtmlx.com/zvcwm2bk
If you want to recalculate the task dates later, you need to use the getClosestWorkTime
method and specify the hour
unit:
https://docs.dhtmlx.com/gantt/api__gantt_getclosestworktime.html#:~:text=00%3A00%3A00-,unit,-a%20time%20unit
If a task has its own calendar, you need to specify the task
parameter, then Gantt will use the task calendar.
Here is the snippet:
https://snippet.dhtmlx.com/zvcwm2bk
In both cases, the dates will be recalculated depending on the working time settings.
https://snippet.dhtmlx.com/6y6i2s51