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');
Asked
Active
Viewed 3,025 times
1
-
1If you're using fullCalendar 3 (or earlier), then there is no alternative because that version is a jQuery plugin, so you have to use jQuery syntax to access it. (And if you're using a later version of fullCalendar then this is the wrong syntax to begin with anyway, so the question wouldn't make sense). – ADyson Mar 18 '21 at 23:04
-
P.s. the newer versions of fullCalendar have a specific React plugin, if that helps. – ADyson Mar 18 '21 at 23:06
3 Answers
2
Hope its working
<FullCalendar
datesSet={(arg) => {
console.log(arg.start) //starting visible date
console.log(arg.end) //ending visible date
}}
/>

Raja Faizan
- 43
- 1
- 7
1
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
}}
/>

Arif Hossain
- 21
- 1
-1
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)}
/>

Jheysson Urbano
- 55
- 5