Reputation: 450
I'm using FullCalendar plugin(week view) for jQuery in my project. In FullCalendar week view, I can see a row showing the date in following format:- Sunday 9/6, Monday 9/7, Tuesday 9/8 so on...
var calendar = $('#calendar').fullCalendar({
header: {
left: 'prev',
center: 'title',
right: 'next'
},
defaultView: 'basicWeek'
});
Now I have used only header format in calendar for time sheet project. I want to get dates 9/6, 9/7 from current selected week in alert when move to next/previous week (this is for store date in database). It is possible to get dates separately for current week?
Upvotes: 5
Views: 11107
Reputation: 16837
You can get the begin & end dates from fullcalendar like this:
let currentDate = $('#calendar').fullCalendar('getDate');
let beginOfWeek = currentDate.startOf('week');
let endOfWeek = currentDate.endOf('week');
Edit:
You can add the events
configuration for fullcalendar. This way you will get the start & end dates when switching views and it also lets you fetch events and render them on the calendar.
events: function(start, end, callback) {
// request the back-end and call the callback when the ajax is done
$.get('events/get', function(result) {
callback(result);
});
}
Upvotes: 5