Setting a Date via http-functions creepy behavior

Hi
I know there are differences between server time and browser time, that not the issue.

The thing is that I create 2 Dates and save it in a collection insdie http-functions. For both Dates I set the time to 00:00. And here it is getting creepy:

When I set the date to 02/03/2022 00:00, it’s been saved in the collection as March 2, 2022 02:00 AM
and when I set the date to 30/03/2022 00:00, it’s been saved in the collection as March 30, 2022 03:00 AM!!!

What makes the differences between the hours??? it is crucial for me because all my function is to check time between two renting dates…

Please explain me this, Thanks!

my code:

startRent = new Date ( 2022 , 2 , 2 , 0 , 0 ); // I also tried with 2 more 0 at the end
endRent = new Date ( 2022 , 2 , 30 , 0 , 0 );

let toInsert = {
“rentDate” : startRent ,
“returnDate” : endRent
};

wixData . insert ( “Rentings” , toInsert );

Seems to me that this is because of Daylight Saving Time - Daylight saving time 2022 in United States will begin at 2:00 on Sunday, March 13.

If you are in another country, then check the local DST rules.

Thanks a lot! I had no idea… I’m from Israel :wink:
I will fix the code accordingly

@theclicksapps Daylight saving time 2022 in Israel will begin at 2:00 on Friday, 25 March.

@yisrael-wix yap, checked it already and wrote the code to deal with it. Thank you Yisrael