I am getting confused with javascript dates but within my app, I am using the following npm package: rc-datepicker
Here the user clicks on a date, which is 21/11/2021 but for some reason, within state, it is being stored as:
2021-11-20T23:25:43.223Z
which is the day prior.
I have got a console log of the date that is being passed through, which is in the following format:
Sun Nov 21 2021 10:25:46 GMT+1100 (Australian Eastern Daylight Time)
Can someone pls assist on how to ensure that the 21/11/2021 is returned and ignore the timezone, if that is the issue or something else?
+1100It's simply UTC vs local time (but the same moment in time)date.toLocaleDateString('en-GB')see: Date.prototype.toLocaleDateString(). Keep in mind that without explicitly providing a timezone it will use the timezone of the users local machine.