1

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');

  • 1
    If 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 Answers3

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
    }}
  />
-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)}
/>