React Calender selects previous dates

41 views Asked by At

I am trying to use React Calender package for my Next.js application for date picking. The problem that I have is that starting from the Month of October, from day 10th, each time I select a date, the previous date gets selected. For instance, if I select 11th, it gets to display 10th as selected and when I console.log() it shows that it selected 10th. This continues until December and from January, every date selected reflects properly. I attached an image screen shot. I actually selected day 16 but it was day 15 that got selected and shown instead of day 16 that I clicked. When I console.log the output I found this:

Wed Oct 15 2025 17:00:00 GMT-0700 (Pacific Daylight Time)

How do I resolve this? enter image description here

My codes so far: The code where the initial date was generated:

  startDate:  dayjs(new Date()).format('YYYY-MM-DD')
  endDate: dayjs(new Date()).format('YYYY-MM-DD')

The calender component rendered like this:

  < Calendar
     value={dateState}
    onChange={(e)=>dateStateFunc(e, eventType, actionDependencies)}
   />

Where I used the calender component:

  < CustomDatePicker
    dateState={new Date(tripsData?.startDate)}
   />
0

There are 0 answers