Zobrazení data v PostgreSQL v určité časové zóně

K zobrazení času v určité časové zóně se v PostegreSQL používá at time zone + zóna.

select created_at at time zone 'CEST' as cest, created_at at time zone 'GMT' as gmt, created_at at time zone 'EST' as est from table_name;

+--------------------------+--------------------------+--------------------------+
|cest                      |gmt                       |est                       |
+--------------------------+--------------------------+--------------------------+
|2021-05-06 13:13:44.360009|2021-05-06 11:13:44.360009|2021-05-06 06:13:44.360009|
|2021-05-06 13:13:43.676227|2021-05-06 11:13:43.676227|2021-05-06 06:13:43.676227|
|2021-05-06 13:13:43.578580|2021-05-06 11:13:43.578580|2021-05-06 06:13:43.578580|
+--------------------------+--------------------------+--------------------------+

Zdroj: popsql.com/learn-sql/postgresql/how-to-convert-utc-to-local-time-zone-in-postgresql

Napsat komentář