Home > front end >  Keep user offset in postgresql database timestampz
Keep user offset in postgresql database timestampz

Time:11-05

I have a postgresql database that I use to store datetimes that includes timezones (utc offsets). I used the timestampz type as it seems to be what I need, but when I insert a datetime, the UTC offset get converted to UTC 00:

For example, if I insert 2022-10-20 00:00:00 01 the actual data stored becomes 2022-10-19 23:00:00 00.

This doesn't look like mutch but we lost some information in the process. Is there a way to keep the offset without adding a column to store that information (or the timezone)?

CodePudding user response:

No, and in that respect PostgreSQL arguably diverges from the SQL standard. If you want to retain the time zone information, you need an additional column. If you do that, consider storing IANA time zone names like Europe/Paris rather than UTC offsets.

  • Related