-
Notifications
You must be signed in to change notification settings - Fork 10
Timestamps convert incorrectly #1285
Copy link
Copy link
Open
Description
Timestamps are off by 5 hours after being localized.
my guess:
- when you save, it converts to UTC in DB (ET is currently at -4). that is correct behavior i think.
- but since we don't have timestamps in the db, when you get it back i guess either the browser or node thinks it's again in your local time (18:35 at -4UTC), but then converts it back to UTC again (adding another +4).
ive run into something similar in the past too, it's quite tricky to get right and "just" displaying the date quickly leads to hydration errors. eg if we send <span>{new Date()}</span> from the server at 12:00 (in -4) to me (in +2, so at 18:00), hydration fails bc my browser thinks that should be 18:00 while the server sends over 12:00.
here's an article that has some solution, but it's still kinda wack: https://francoisbest.com/posts/2023/displaying-local-times-in-nextjs
my suggestion: keep it as is, and we open a separate ticket to address hydration related issues dealing with time!
Originally posted by @tefkah in #1270 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels