【发布时间】:2018-10-01 08:39:33
【问题描述】:
我很难使用 postgresql 和时区。
Postgresql 服务器位于 UTC 时区。 我想执行一个查询,返回具有时区偏移的另一个时区中的日期。
我可以执行返回时区日期的查询,但 我缺少时区偏移量
base=# SET timezone to 'utc';
SET
base=# select now();
now
------------------------------
2018-04-20 14:58:22.68038+00
(1 row)
base=# SET timezone to 'Europe/Paris';
SET
base=# select now();
now
-------------------------------
2018-04-20 16:58:29.614383+02
(1 row)
base=# SET timezone to 'utc';
SET
base=# select now() AT TIME ZONE 'Europe/Paris';
timezone
----------------------------
2018-04-20 16:59:03.146917 -- missing timezone offset here
(1 row)
预期结果
base=# SET timezone to 'utc';
SET
base=# select now() AT TIME ZONE 'Europe/Paris'; --I'm missing something here, I guess
timezone
----------------------------
2018-04-20 16:59:03.146917+02 -- That's what I want
(1 row)
你知道怎么做吗?
谢谢
【问题讨论】:
标签: postgresql