How to save Enddate


Hello, how do I save “enddate” when I save “stratdate” and “duration”?


Hi @isWFF,
If I understand you correctly, you want to save 3 data properties( end_date , start_date and duration ). Unfortunately, you can store only 2 of them at the same time, the 3rd will be calculated automatically. So, if you need exactly end_date , you can remove start_date or duration .
If I misunderstood you, could you please clarify the question?


OK, what should I do if I want to save the start date and end date now?


Hi @isWFF,
If you meant a start_date - end_date controller in the lightbox, you can add the time section to the gantt.config.lightbox.sections, like in the following snippet:
Time control: https://docs.dhtmlx.com/gantt/desktop__time.html
Configuring lightbox: https://docs.dhtmlx.com/gantt/api__gantt_lightbox_config.html

btw, in the gantt you can change task data by using inline editing in the grid, you can read more about this functionality by the following link:

If it is not what you need, could you please clarify where exactly you want to save start_date and end_date, maybe you have the problem with saving dates in the database?


I want to save enddate instead of duration. The above example still saves duration, but duration is calculated by startDate and enddate


Hi @isWFF,
Sorry, I don’t think I’ve understood your question correctly.
When you save the lightbox (the details form) the task has all three properties defined - start_date/end_date/duration.
Can you please clarify what exactly do you mean by saving the end date instead of duration?
Are we talking about saving these properties to the database(backend), or are we still on how things are stored or calculated on the client-side?

btw, I updated the old example and added getting start/end dates functionality inside onLightbox/onLightboxSave events:
To check how it works you should:

  1. Open console in browser developer tools
  2. Double click on a task (the start/end dates will be displayed in the console)
  3. Change dates and click save button in the lightbox (modified dates will be displayed in the console)



If the data I want to save in the database is the end date and duration, is there any way to achieve it? Or although Gantt chart provides three modes for us to choose in the light box, the three modes of data saved in the database are start date and duration?


Hi @isWFF,
Thank you for the clarification.
By default, our client sends all 3 parametres (start_date, end_date, duration) to the server.
If you want to have only 2 of them saved in your database, you should change code in your server-side, which is responsible for loading and saving data, to save only two of them. I couldn’t give you more detailed recommendations without an example of your server-side code responsible for loading and saving data.

If you check any of our “How to start” tutorials, you can see how the tasks are saved to the database:
https://docs.dhtmlx.com/gantt/desktop__howtostart_dotnet_core.html#step4implementingwebapi - you’ll need to scroll down a bit until you find “TaskController” definition and the line: // PUT api/task/5.

    // PUT api/task/5
    public ObjectResult Put(int id, WebApiTask apiTask)
        var updatedTask = (Task)apiTask;
        var dbTask = _context.Tasks.Find(id);
        dbTask.Text = updatedTask.Text;
        dbTask.StartDate = updatedTask.StartDate;
        dbTask.Duration = updatedTask.Duration;
        dbTask.ParentId = updatedTask.ParentId;
        dbTask.Progress = updatedTask.Progress;
        dbTask.Type = updatedTask.Type;


        return Ok(new
            action = "updated"

You can see that all saved fields are listed there explicitly, you can change one for another.
The same can work for implementations in different languages, e.g.

public function update($id, Request $request){
    $task = Task::find($id);

    $task->text = $request->text;
    $task->start_date = $request->start_date;
    $task->duration = $request->duration;
    $task->progress = $request->has("progress") ? $request ->  	   progress : 0;   
    $task->parent = $request->parent;


    return response()->json([
        "action"=> "updated"

You have full control over the code that writes changes to the database, and you should be able to configure it to fit your purposes.


I see. Thank you.
Is there any way for this control to implement reverse task scheduling, that is, to give the end date of the last task and push the end date of the previous task