search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Get the current date?

Asked by Chris Kachinsky
2 years ago.

Hi there. I'm trying to use the scheduler and the navigator together. I have them working nicely, allowing me to move through dates.

I've been reading about the navigator and the events.list - but I'm struggling to get it working at present. I'm trying to just write a js function to get the json for the events in the current month, but how do I get the date we're currently looking at?

If I open the console and type `dp.dp.startDate.value` - I get a reply with the correct date, but for some reason I cannot do this automatically. Even with a setTimeout, it still doesn't work...

Any ideas?

Thanks, Chris

Answer posted by Dan Letecky [DayPilot]
2 years ago.

If you want to get the date that was last clicked in the Navigator, you can read the selectionDay property:
https://api.daypilot.org/daypilot-navigator-selectionday/

const nav = new DayPilot.Navigator("nav");
// ...


const current = nav.selectionDay;

If you use selectMode other than "Day", you can use selectionStart and selectionEnd to get the full selected range:
https://api.daypilot.org/daypilot-navigator-selectionstart/
https://api.daypilot.org/daypilot-navigator-selectionend/

To read the date range currently displayed by the Navigator, you can use visibleStart() and visibleEnd():
https://api.daypilot.org/daypilot-navigator-visiblestart/
https://api.daypilot.org/daypilot-navigator-visibleend/

The visibleStart() method returns the date in the top-left corner and the visibleEnd() method returns the date in the bottom-right corner. You can use these methods if you want to load the free/busy data (to be assigned to events.list).

Please let me know if this is not what you are looking for.

Answer posted by Chris Kachinsky
2 years ago.

Thanks Dan.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.