Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遇到的问题如下:当我在页面上显示日期时,它们显示的日期比数据库中存储的日期少 1 天。我该如何解决这个问题?
我注意到数据库中的日期是 1984-12-30 00:00:00,这意味着它在 12 月 30 日开始,但时区是 +2。在我的项目的 settings.py 中,我注意到 TimeZone 是 UTC(即 +0),这意味着 UTC 的 DateTime 实际上是 1984-12-30 22:00:00(落后 2 小时)。
我通过将 Django 服务器的 TimeZone 更改为 +2 Timezone 来解决此问题,因此日期可以正确表示。
编辑:错别字