diff --git a/PostgreSQL/time.sql b/PostgreSQL/time.sql new file mode 100644 index 0000000..a7ee605 --- /dev/null +++ b/PostgreSQL/time.sql @@ -0,0 +1,10 @@ +-- 设置会话时区 +SET TIME ZONE 'Asia/Shanghai'; + +-- msg_time 是 timestamptz类型 +select msg_time from msg where id = 1; +select msg_time AT TIME ZONE 'Asia/Shanghai' from msg where id = 1; +select msg_time AT TIME ZONE 'UTC+8' from msg where id = 1; + +SELECT to_timestamp(1761850339); +SELECT to_timestamp(1761850339) AT TIME ZONE 'Asia/Shanghai';