I am building (using a code) a system for booking accommodations.
After the user selects a room and enters dates, the data is sent to the server-side and there the costs are calculated.
I encountered the following problem: The dates selected by the user sent to the server-side and there it changes to the date of the previous day.
I understand that this is probably due to a difference between the time on my computer and the time on the server computer (located elsewhere in the world).
What is the right way to handle it so that it will work for customers from different time zones and also for Daylight saving time ?
I will note that the business for which I am building the site is from Israel and the vast majority of customers are from Israel, so I prefer to use Israel time rather than server time.
Attaches examples with sample prints:
client-side:
console.log("checkin date on client-side: " + $w('#datePicker1').value);
let arrayOfReturn = checkDatesAndPrices($w('#datePicker1').value, $w('#datePicker2').value); //send dates to function on server-side
server-side:
export function checkDatesAndPrices(checkinDate, checkoutDate) {
console.log("checkin date on server-side: " + checkinDate);
.....
}
The prints:
checkin date on client-side: Mon Dec 14 2020 00:00:00 GMT+0200 (Israel Time (Winter))
checkin date on server-side: Sun Dec 13 2020 22:00:00 GMT+0000 (Coordinated Universal Time)
Thank you!