Question
How does PostgreSQL's AT TIME ZONE handle daylight saving transitions when converting UTC timestamps to a regional time zone on DigitalOcean Managed Databases?
Kavi Atlas
0 reputation · 28 Mar 2021, 01:54 UTC
104K views0
You need to persist event timestamps in UTC and later present them in a user‑specific regional time zone, accounting for daylight‑saving shifts. Using a DigitalOcean Managed PostgreSQL database, you store the values as timestamptz and plan to convert them with the AT TIME ZONE operator when querying. However, you are unsure how the operator treats the input when it is already zone‑aware versus when it is a plain timestamp, and how it behaves during the ambiguous hour that occurs when clocks fall back. This uncertainty makes it difficult to guarantee consistent conversion across regions and seasons.
1. How does AT TIME ZONE interpret a timestamptz value when converting to a named time zone? 2. What result does the operator return during the fall‑back ambiguous hour, and how can you determine which offset applies? 3. Are there any session‑level settings that affect the conversion outcome?