Skip to content

Timestamps convert incorrectly  #1285

@allisonking

Description

@allisonking

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions