2 ms·
> I guess one could use timestamptz with a constraint saying that timezone is UTC, but is there a point? There's no need for constraints, that's exactly what t
by masklinn 8y ago
> I guess one could use timestamptz with a constraint saying that timezone is UTC, but is there a point?
There's no need for constraints, that's exactly what timestamptz does. If it's provided a zoned datetime it'll convert that to UTC then store it, if provided a non-zoned datetime it'll assume that's in the local tz ("timezone" system setting) and performs the same conversion.
timestamp, by comparison, will just discard any timezone information (if it's given a zoned timestamp it'll simply discard the timezone information and store the timestamp's value as-is).
> Timestamps in DBs should never be non-UTC…
That only works for past events. Storing future events in UTC is usually broken, because future events are normally relative to a specific timezone (e.g. a meeting at 6 in Tusla, or a party at 8 in Melbourne). If you store them in UTC and the timezone's offsets change your occurrence is now incorrect.