Convert a UTC timezone in postgresql to EST (local time)

后端 未结 6 1057
野趣味
野趣味 2020-12-24 11:00

I am new to PostgreSQL and I was wondering if there is a direct way to just convert the timestamp values in a table to a different timezone using a function. In my case it i

6条回答
  •  孤独总比滥情好
    2020-12-24 11:26

    You should always store the main reference of a date in UTC and either convert it to a time zone in your queries or store the specific timezone version of the data in another column. The reason for this is that it is quick and easy to convert a date from UTC to another time zone as long as you know that the timezone that it is stored as is UTC. It takes the guess work out of it. Alternatively, you can store the date WITH the timezone.

    If you have an operation that automatically populates the date with the system clock of your server, then you can either A: Change the operation to use UTC time B: Change the system clock on the server to UTC

提交回复
热议问题