0

I am using Mobiscroll Datepicker for my react application. I have to select multiple dates for scheduling classes. Everything is working fine except that the dates that are being dispatched to redux is one less than the date being selected. Here is the code My date picker component

<Datepicker
            controls={['calendar']}
            display="inline"
            selectMultiple={true}
            value={Course.dayOfWeek}
            onChange={handleDayChange}
        />

The onChange function:

const handleDayChange=(e)=>{
    console.log(e.value)
    dispatch(setDayofWeek(e.value))
}

The values being consoled: ScreenShot of console

0: Tue Jul 05 2022 00:00:00 GMT+0500 (Pakistan Standard Time) {}

1: Tue Jul 12 2022 00:00:00 GMT+0500 (Pakistan Standard Time) {}

2: Tue Jul 19 2022 00:00:00 GMT+0500 (Pakistan Standard Time) {}

The values being dispatched to redux redux screenshot

0(pin):"2022-07-04T19:00:00.000Z"
1(pin):"2022-07-11T19:00:00.000Z"
2(pin):"2022-07-18T19:00:00.000Z"

The redux should store 5,12,19 but is storing one day less. What is being done wrong here?

1 Answers1

0

It's because the values being displayed in console are in GMT+5. While the values being dispatched to redux are in ISO format. Maybe the timezone difference is what is causing the issue. Try dispatching it in the same GMT+5 format.