Reputation: 11
What is alternative solution for below piece of code if I wanted to write use this in React js or simple Javascript ? var startDate = $('#calendar').fullCalendar('getView').intervalStart.format('DD/MM/YYYY'); var endDate = $('#calendar').fullCalendar('getView').intervalEnd.format('DD/MM/YYYY');
Upvotes: 1
Views: 5756
Reputation: 107
Get current month where January = 1, December = 12
const getCurrentMonth = (arg) => {
const startDate = arg.view.activeStart
if (arg.view.type === 'dayGridMonth'){
console.log('Current Month', startDate.getMonth() + 1 )
return
}
if( arg.view.type === 'dayGridDay'){
startDate.setDate(startDate.getDate() + 8)
console.log('Current Month', startDate.getMonth() + 1 )
}
}
<FullCalendar
datesRender={(arg) => getCurrentMonth(arg)}
/>
Upvotes: -2
Reputation: 73
<FullCalendar
datesSet={(arg) => {
console.log(arg.start) //starting visible date
console.log(arg.end) //ending visible date
}}
/>
Upvotes: 4
Reputation: 21
you can use datesRender
props to get the active month range.
<FullCalendar
datesRender={(arg) => {
console.log(arg.view.activeStart) //starting visible date
console.log(arg.view.activeEnd) //ending visible date
}}
/>
Upvotes: 1