How to get the date and time of visible view

Hi,

I want to get the current time of the visible view. I have create a little snippet here using scheduler.getState().date, but this does not give the right date-time.
http://docs.dhtmlx.com/scheduler/snippet/29f765a7
I have added a button ‘Show date’ to find the current date-time of the visible rectangle.
Is there a way to get that time?

Thanks

Hi,

You got Tue Jun 30 2009 00:00:00 GMT+0300, because the same date set in the scheduler.init(). If you swith to the next time range by “next button”, you will get the min date of the current view.
Which time do you expect to get?

Hi,

I want to get the time of visible rectangle top-left. In this examples 8:00.

Hi,

In this case you can eather get the value of scroll_hour config

or get the scrolled position of the Scheduler container http://prntscr.com/o2ymaj and then use this value in the getActionData to get time
https://docs.dhtmlx.com/scheduler/api__scheduler_getactiondata.html

This example demonstrates how it works for the cursor position
https://docs.dhtmlx.com/scheduler/samples/09_api/01_action_data.html

Hi Polina,

scheduler.config.scroll_hour always gives you the initial value. In this case 8. Also after scrolling it gives 8.

I am not interested in the cursor position. I want to get the live top left time.

Hello, any update on this?

Hello @Cesar_Smerling,

In current scheduler version, you can use the dateFromPos method, that takes left value of the scrollbar as a parameter, like follows:

  var timeline = scheduler.getView(); 
  scrollState = timeline.dateFromPos(timeline.getScrollPosition().left)

You can just use scheduler.getState().min_date and scheduler.getState().max_date to get the min and max of the current view.