From c8de605ed75ae77b6d720653cd9dd539ed9328ac Mon Sep 17 00:00:00 2001 From: Fortern Date: Fri, 31 Oct 2025 03:36:30 +0800 Subject: [PATCH] update --- PostgreSQL/time.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 PostgreSQL/time.sql 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';