-
I'm building a Next.js full-stack app and want to save the date from Date-Picker in my database. At first, I tried to work only with dates but there was always a 1-day difference between my date in the localhost and the date sent to the database. I realized that new Date() is a timestamp so I might as well use timestamptz for my data format in the database. Now there's a 4-hour difference between my time in the localhost and the time sent to my database. PS: hasMounted state is used so that there's no hydration error on reload
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
React-Date-Picker returns local, native JavaScript Date. It's likely not "one day off", it's rather "In Greenwich, it's still yesterday/already tomorrow at this time". My personal advice would be to keep it as it is, because working with anything else than UTC will be the start, not the end of your timezones nightmare. |
Beta Was this translation helpful? Give feedback.
React-Date-Picker returns local, native JavaScript Date. It's likely not "one day off", it's rather "In Greenwich, it's still yesterday/already tomorrow at this time".
My personal advice would be to keep it as it is, because working with anything else than UTC will be the start, not the end of your timezones nightmare.