I have implemented fullcalendar in my application. I am facing a problem for getting current displayed date range. I want to get currently displayed date range in full calendar. Please suggest me a proper solution.
For example please take a look on this image
In this I want to get "20 Sept" and "26 Sept".
You can also dynamically generate the range via a function. It must return an object in the same format: var calendar = new Calendar(calendarEl, { initialView: 'dayGridMonth', validRange: function(nowDate) { return { start: nowDate, end: nowDate.
We can get start date by getView event with intervalStart. We can get end date by getView event with intervalEnd. var month = $('#calendar'). fullCalendar('getView').
The calendar's dates can change any time the user does the following: click the prev/next buttons, change the view, click a navlink. The dates can also change when the current-date is manipulated via the API, such as when gotoDate is called. datesSet is called after the new date range has been rendered.
Try this.
Add this function and call this. It will help you.
function GetCalendarDateRange() {
var calendar = $('#calendar').fullCalendar('getCalendar');
var view = calendar.view;
var start = view.start._d;
var end = view.end._d;
var dates = { start: start, end: end };
return dates;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With