reactjsreact-daterange-picker

react-daterange-picker display previous month on a side by side view


I am working with this react date range calendar plugin I have two months side by side using showDoubleView={true} It is displaying the current month + the following one. Which is the default behavior

But now I want to display the previous month + the current month. How can I specify it?

here's a sample of my code

<DateRangePicker
                onChange={handleValueChange}
                value={calendarValue}
                closeCalendar={true}
                format={'dd-MM-y'}
                showDoubleView={true}
                minDetail={'year'}
                showNeighboringMonth={true}
                selectRange={true}
            />

I tried to set activeStartDate={new Date(2021/2/1)} but the calendar displays the year 1970


Solution

  • Make sure you don't forget to put quotation marks around your date. Maybe this is the problem of 1970 year. For example:

    new Date(2021/2/1) // outputs Wed Dec 31 1969 19:00:01 GMT-0500 (Eastern Standard Time)
    
    new Date('2021/2/1') // outputs Mon Feb 01 2021 00:00:00 GMT-0500 (Eastern Standard Time)