Timestamps and Time Zones in PostgreSQL (2016)
I completely disagree with this advice:> However, when you come across timestamp, you can’t possibly know in what time zone the timestamp is just by looking at it.yes I do, it's in UTC, because I assume the application is written to correctly handle datetimes.> It is merely a wall time. Maybe it’s UTC,no, it's UTC.> or maybe the developer stored it in local time.right, maybe the application was not programmed correctly, that is always a possibility. But if they are using the timestamp with timezone datatype, it is 100% more likely they have made mistakes in doing so because it is much more confusing to have to fight against PostgreSQL's assumptions and implicit conversions, as the complexity of its behaviors and decisions using this datatype are described in this article.   Does the application come up with the wrong answer if the server it runs on, or the webserver container, is mistakenly set to Eastern Timezone rather than UTC?   Is the application ensuring that it knows the correct timezone of timestamps as they enter the application, and if so, why isn't it converting to UTC at that moment?   Is the application otherwise receiving datetimes of arbitrary timezone, letting them move around business and display logic in their raw form, and waiting until they enter the database to be correctly normalized?  that's too late.A correctly coded application does explicit normalization of datetime values the moment they enter the boundaries of the application, just like it would also convert encoded bytes into a unicode-aware strings up front, so that within the application there is no ambiguity, both when persisting and when handling.