How to get the timezone from a PostgreSQL timestamp

The documentation on Postgres timestamps says:

For timestamp with time zone, the internally stored value is always in UTC (Universal Coordinated Time, traditionally known as Greenwich Mean Time, GMT). An input value that has an explicit time zone specified is converted to UTC using the appropriate offset for that time zone. If no time zone is stated in the input string, then it is assumed to be in the time zone indicated by the system's TimeZone parameter, and is converted to UTC using the offset for the timezone zone.

Contrary to what a reasonable person might expect when reading timestamp with time zone, this Postgres datatype doesn't actually store a timezone. Internally, the value is always converted to UTC.

The information about the input timezone is lost when saving the value to the database. As far as I know, there is no way to get the information you seek.


The data you want does not exist. Timestamps do not contain time zone data. Timestamps are always stored in UTC. The time zone information is used to convert to UTC on the way into the database, and to format UTC into some other format on the way out. It is not stored, unless you create an additional column to store it in.

Tags:

Postgresql