Task Bar shows one day less

I’m loading Task dates as “start date + end_date” , however in chart it always shows one day less. How to fix this issue? Please help.


Hi,

In your case end_date is 30/06/2016. So it means that your event finishes June 30th at 00:00 and covers June 29th and doesn’t cover June 30th. If you want to fully cover June 30th you should set end date “2016-07-1” or “2016-07-1 00:00”. Maybe you could at least use “2016-06-30 23:59:59”, but correct case is to use “2016-07-1” or “2016-07-1 00:00”.
If it necessary for you, you could correct event dates in onTaskLoading handler.
docs.dhtmlx.com/gantt/api__gantt … event.html

Dear Polina,

Thanks for your reply.
In our case when we display end_date as 30/06/2016. which means that task finishes June 30th (including full day). I cannot change the dates here because application users will be confused.
Is there any way to extend the task bar by one day without changing the dates ?

Hello,

Unfortunately, it’s not possible.
As I wrote in previous reply, you could use “2016-06-30 23:59:59”, if you need to include full day of June 30th.

hello,
I have set my end date to “2024-09-06 23:59:59” like [{end_date=2024-09-06 23:59:59, dur=7, parent=0, name=needs, id=1, resid=null, open=true, start_date=2024-08-31},but the chart shows one day less ,
please help!

Hello,
Please don’t ask the same questions in different places. Let’s continue our discussion here:

hello,
thanks for your apply, I have solved this problem for setting end_date’s formatter from %Y-%m-%d to %Y-%m-%d %H-%m%s,thank you for giving me idea.

请问你咋解决的,我的结束日期是 2024-11-16 23:59:59 还是不生效
gantt.config.xml_date = ‘%Y-%m-%d %H:%m:%s’; gantt.config.duration_unit = “hour”;
gantt.config.work_time = true; gantt.config.date_format = “%Y-%m-%d %H:%m:%s”; 但是还是不行

Hello,
Modifying the end_date is not recommended. This is an obsolete approach and may not work as expected. There are better ways to handle that.

Gantt uses the non-inclusive duration. There is no way to change how Gantt works, but you can change what is displayed to the users by using the templates:
https://docs.dhtmlx.com/gantt/desktop__loading.html#taskenddatedisplayampinclusiveenddates
https://docs.dhtmlx.com/gantt/api__gantt_task_end_date_template.html
Here is an example of how it works:
https://snippet.dhtmlx.com/ici6m0dp

Also, you can set the duration_unit to ‘hour’ and enable the work_time parameter:
https://docs.dhtmlx.com/gantt/api__gantt_duration_unit_config.html
https://docs.dhtmlx.com/gantt/api__gantt_work_time_config.html
Gantt will show the same dates in the grid because the hours will be different.
To show the duration in days and even in fractional values, you can use the formatters:
https://docs.dhtmlx.com/gantt/desktop__formatters_ext.html#durationformatter

Here is an example with the date input type in the inline editors:
https://snippet.dhtmlx.com/w5hrv69x
Here we need to modify the dates because the input element with the date type doesn’t have the hour values.

Here is another example with the datetime-local input type in the inline editors:
https://snippet.dhtmlx.com/gjrgzm0p
The input element may take more space, but it will store the dates more accurately.

但是我并不想用那个data内编辑器,因为我自己在表单提交的的时候已经填写了,enddata,并不想在外面在修改日期。还有我也并不想修改显示的日期,我只想,吧enddata设置为23:59:59 秒这个样,满足当天结束任务的需求,

Hello,

But I don’t want to use the data editor, because I have already filled in the enddata when submitting the form, and I don’t want to modify the date outside. And I don’t want to modify the displayed date, I just want to set the enddata to 23:59:59 seconds to meet the needs of ending the task on the same day.

As I said before, there is no way to change how Gantt works. The easiest way is to modify what is displayed to the user.
Another way is to modify the end_date before you apply the changes. But it is more like a workaround, and it is not expected to work correctly.

Also, Gantt doesn’t have the second scale and duration_unit. The lowest available unit is "minute":
https://docs.dhtmlx.com/gantt/api__gantt_duration_unit_config.html

So, if you specify both the start_date and end_date parameters for the task object, Gantt will place that task on the specified dates. But as the lowest duration_unit is minute, Gantt will round the duration to 0 when it is less than 0.5 minutes, or to 1 when it is between 0.5 and 1 minutes.
Here is an example:
https://snippet.dhtmlx.com/zgzxtx92

Also, after you drag or update a task, the duration will be rounded to minutes.
So, you need to create a custom unit and manually handle that and restore/update the dates to seconds:
https://docs.dhtmlx.com/gantt/desktop__configuring_time_scale.html#customtimeunits

The following example can help you to start implementing your solution:
https://snippet.dhtmlx.com/vo2zpi4d

If that doesn’t help you, probably, the issue is related to the Gantt configuration, but it is hard to suggest what might be wrong as I don’t see your code.
In that case, please add your configuration to the following snippet and make sure that the issue is reproduced there:

Then, click on the Save button and send me the link.
Or send me a ready demo with all the necessary JavaScript and CSS files so that I can reproduce the issue locally.


Also, please add comments only in English so that everyone can understand them.