‹ BackHN Continuity

Thread

Footguns with Postgres “at time zone 'UTC'”

169 points · 114 comments · birdculture

  1. braiamp · · focus · HN ↗
    This is why you store two dates: what the user sent and what you need for calculations. What the user sent becomes your oracle and what you show the user (date time + timezone) and your derived utc to do datetime arithmetic
    1. ekejjedjndbd · · focus · HN ↗
      If the UTC is derived why store it (unless just as a performance concern e.g. materialised view type of thing)
      1. christina97 · · focus · HN ↗
        Presumably if the conversion logic changes. Eg user enters a future date in a place but the timezone in that place changes in the future.
        1. ekejjedjndbd · · focus · HN ↗
          That's a good point although I would prefer to have a deterministic conversion that handles historic changes. But I get the point and having a source of truth for the conversion could be better as it won't be affected by bugs in the conversion of deemed right. It does mean maintaining two values though.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.