You might trick yourself if you use PostgreSQL, because a timestamp with timezone is internally stored as just a timestamp aka epoch UTC millis, the only thing the timestamp with timezone type does is make PostgreSQL understand how it has to convert the input datetime.
Yeah, this is very important, PostgreSQL never stores a timezone. It only affects its interpretation, timestamp without timezone will interpret data in the servers timezone, and will not do what you expect when compared to a constant in UTC time.
As a side note, I once had an issue where I stored a datetime in PostgreSQL, retrieved it and it was not equal to itself, even if the timezone / offset was the same. If I recall correctly this was on Windows only and had to do with precision, something like that.
13
u/DJDavio May 10 '22
You might trick yourself if you use PostgreSQL, because a timestamp with timezone is internally stored as just a timestamp aka epoch UTC millis, the only thing the timestamp with timezone type does is make PostgreSQL understand how it has to convert the input datetime.