I have a hotel booking website ,so the problem is when the users who are residing in India and have IST time zone tries to book any hotel then the date they’re seeing is correct but when users who are outside IST time zone for example Eastern Daylight time zone they’re not able see correct date when they select it from calendar
I have set my laptop to EST time zone and when I select 7th of september 2024 from calendar and I can see props.checkin also has the same date but when it is passed to new Date(props.checkin) then the date automatically changes to 6th of september 2024 and this only happen in time zone other then IST
useEffect(() => {
console.log(
"props.checkin>>>>>",
new Date("Sat Sep 07 2024 00:00:00 GMT+0530 (India Standard Time)"),
);
dispatch(
updateBookingDateRange({
checkInDate: new Date(props.checkin),
checkOutDate: new Date(props.checkout),
searchedRoomCount: Number(props.num_rooms),
searchAdultCount: Number(props.num_adults),
searchedChildrenCount: Number(props.num_children),
searchGuestCount: Number(props.num_guests),
}),
);
if (
totalRoomCount === 0 &&
props.planStatus &&
router.query.roomId &&
router.query.planId
) {
dispatch(
addFirstRoom({
roomInfo: props.roomDetails,
planInfo: props.planDetails,
roomCount: props.num_rooms,
guestCount: Number(props.num_guests),
adultCount: Number(props.num_adults),
childCount: Number(props.num_children),
}),
);
}
}, [
router.query.hotelInfo,
router.query.checkin,
router.query.checkout,
router.query.num_guests,
router.query.num_children,
router.query.num_rooms,
]);
I’m expecting that when users that are in different time zone chooses some date then they too should see correct date instead of wrong date.