【发布时间】:2019-06-13 09:57:25
【问题描述】:
我正在保存到 db DateTime,例如:
2019-02-25T11:30:26+03:00
然后在 DB 中它看起来像这样:
2019-02-25 08:30:26.000000 +00:00
转换为 UTC。好的。 然后,当我想在当地时间恢复这个 DateTime 时,我必须
.annotate(check_time_local=Trunc('check_time', 'second', tzinfo=timezone('Etc/GMT+3')))
这将被转换为如下查询:
DATE_TRUNC('second', "table"."dt_field" AT TIME ZONE '-03') AS "check_time_local"
从 DB 获取:
2019-02-25 11:30:26
在 Django 中:
2019-02-25 11:30:26 -0300
为什么不 +3?为什么是-3?
【问题讨论】:
-
postgres中列的数据类型是什么?它是时间戳还是时间戳?我猜它是时间戳,但实际上应该是 timestamptz。
-
带时区的时间戳
标签: django postgresql