PostgreSQL – Timezone for ‘Timestamp Without Timezone’ in psql

postgresqlpsqltimestamp

What I mean is the following: if I create a timestamp without timezone (timestamp) column and store there some value, internally microseconds are stored, but when issuing select this is converted to a string with date and time. But in which timezone the converted time is?
I tried to change timezone in my computer (PostgreSQL is running locally, so I reopened psql), tried changing it in postgresql.conf (restarting the service) and setting timezone per session. However as far as I saw, the output doesn't change. I'm sure I'm missing something. Thanks!

Sample code:

create table tzo (wotz timestamp);
insert into tzo values (now());
table tzo;

Output:

            wotz            
----------------------------
 2020-08-11 17:51:37.244901
(1 row)

Best Answer

timestamp without time zone is time zone agnostic, so it is not adjusted to any time zone on display. This data type just doesn't have a time zone.

You can convert it to a certain time zone with AT TIME ZONE:

SHOW timezone;

   TimeZone    
---------------
 Europe/Vienna
(1 row)

SELECT TIMESTAMP WITHOUT TIME ZONE '2020-08-01 12:00:00' AT TIME ZONE 'UTC';

        timezone        
------------------------
 2020-08-01 14:00:00+02
(1 row)

Then the timestamp is interpreted as Viennese time, converted to UTC and displayed in my local Viennese time zone, which is offset two hours.