Dynamically gets the time on the timescale

Because when rendering the data, I need to decide which time period the data is displayed according to the time scale. For example, I have a data that needs to be displayed in the interval of May 18th to May 31st, but the data of the data set corresponds to the two periods of May 18th to May 20th and May 24th to May 31st.Because this is in the same data set, I need to know exactly what time it is on the right hand side.

Hi @yangyun15757!

You can set the date range explicitly by using the start_date and end_date configuration options:

Here is a sample you can see how it can be implemented for your dates:

Also, you can set the gantt.config.fit_tasks = true. The Gantt chart will automatically extend the time scale in order to fit all displayed tasks. Please check this article:
Please check this sample:

If you meant something different - please clarify.

Since I cannot accurately determine the time of the data set, I need to compare the data set with the time scale.

Hi @yangyun15757!

Sorry, I’m still not sure I completely understand.
Do you mean you need to know the time (min date and max date) of the time scale in gantt?
If so - please check this method https://docs.dhtmlx.com/gantt/api__gantt_getstate.html

For example, if the time scale is many grids, and the current time is one grid, then I need to know the current time of the grid.

Hi @yangyun15757!

Unfortunately the description still not clear. Please send me screenshots:

  1. with many grids
  2. with one grid
  3. display the current time of the grid that you mean.
    I hope screenshots will help me understand your issue and how to solve it.