3 ms·
No, this just makes the default value the UTC time at the time a row is created, but it doesn’t help. Let’s say I create a row at “12:34 5 April UTC”. If I now
by doctor_eval 5y ago
No, this just makes the default value the UTC time at the time a row is created, but it doesn’t help.
Let’s say I create a row at “12:34 5 April UTC”. If I now change client time zones and run a query, the epoch time will change to “12:34 5 April EST”. That’s probably not what you want.
The underlying issue is that most PG functions use timestamptz, and PG silently converts timestamp to timestamptz. This conversion uses the local TZ and can lead to nondeterministic behaviour from the perspective of the SQL expression.
Put another way, timestamptz is perfectly stable, timestamp can be nondeterministic, use timestamptz unless you are absolutely sure you know what you are doing.