4 ms·
Or alternatively, "timestamp without time zone default (now() at time zone 'utc')" is fine as well and does make the time zone explicit in the type definition
by quambene 5y ago
Or alternatively,
"timestamp without time zone default (now() at time zone 'utc')"
is fine as well and does make the time zone explicit in the type definition.
- doctor_eval 5y agoNo, 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.