时区非 UTC 时显示时间不准确 #747

Closed
opened 2026-02-21 17:28:16 -05:00 by yindo · 5 comments
Owner

Originally created by @fisherzrj on GitHub (Nov 28, 2023).

Originally assigned to: @takatost on GitHub.

Dify version

v0.3.32

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. 将部署服务器的时区设置为东八区
  2. 将设置语言中的时区设置为东八区
  3. 随意创建一个应用并使用
  4. 可以发现 日志与标注 中的时间比预期东八区的时间多了八小时

大概看了一下源码,应该是conversations表的创建语句问题,created_at、updated_at 用的是当前时区时间而 read_at 用的却是 UTC 时间,两个时间系统不一致
WX20231128-145554@2x

建议default值使用类似SET DEFAULT timezone('UTC', CURRENT_TIMESTAMP(0))的写法也使用 UTC 时间

另:刚发现直接修改数据库时间会导致 日志与标注 中过滤时间的下拉框不准确,怀疑此处用的时间未转为 UTC 时间

✔️ Expected Behavior

1、时间显示应该与当前时区保持一致
2、数据库中不应该出现多种不同时区的时间

Actual Behavior

时间比当前时区多了八小时

Originally created by @fisherzrj on GitHub (Nov 28, 2023). Originally assigned to: @takatost on GitHub. ### Dify version v0.3.32 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. 将部署服务器的时区设置为东八区 2. 将设置语言中的时区设置为东八区 3. 随意创建一个应用并使用 4. 可以发现 **日志与标注** 中的时间比预期东八区的时间多了八小时 大概看了一下源码,应该是conversations表的创建语句问题,created_at、updated_at 用的是当前时区时间而 read_at 用的却是 UTC 时间,两个时间系统不一致 ![WX20231128-145554@2x](https://github.com/langgenius/dify/assets/33017249/722f2867-bc81-45f3-b0e8-c89855ef53e6) 建议default值使用类似`SET DEFAULT timezone('UTC', CURRENT_TIMESTAMP(0))`的写法也使用 UTC 时间 另:刚发现直接修改数据库时间会导致 **日志与标注** 中过滤时间的下拉框不准确,怀疑此处用的时间未转为 UTC 时间 ### ✔️ Expected Behavior 1、时间显示应该与当前时区保持一致 2、数据库中不应该出现多种不同时区的时间 ### ❌ Actual Behavior 时间比当前时区多了八小时
yindo added the 🐞 bug label 2026-02-21 17:28:16 -05:00
yindo closed this issue 2026-02-21 17:28:16 -05:00
Author
Owner

@crazywoola commented on GitHub (Nov 28, 2023):

Close due to https://github.com/langgenius/dify/issues/1542

@crazywoola commented on GitHub (Nov 28, 2023): Close due to https://github.com/langgenius/dify/issues/1542
Author
Owner

@jinec commented on GitHub (Sep 19, 2024):

@fisherzrj @crazywoola Has this problem been resolved?

@jinec commented on GitHub (Sep 19, 2024): @fisherzrj @crazywoola Has this problem been resolved?
Author
Owner

@fisherzrj commented on GitHub (Sep 20, 2024):

@fisherzrj @crazywoola这个问题找到了吗?

I'm not entirely sure. I solved the issue by setting the server to UTC time, but I haven't tested it since.

@fisherzrj commented on GitHub (Sep 20, 2024): > @fisherzrj @crazywoola这个问题找到了吗? I'm not entirely sure. I solved the issue by setting the server to UTC time, but I haven't tested it since.
Author
Owner

@unsiao commented on GitHub (Nov 25, 2024):

这个问题找到了吗?

我不完全确定。我通过将服务器设置为 UTC 时间解决了这个问题,但此后我就没有测试过它。

Hi 设置 哪个容器的时区

@unsiao commented on GitHub (Nov 25, 2024): > > 这个问题找到了吗? > > 我不完全确定。我通过将服务器设置为 UTC 时间解决了这个问题,但此后我就没有测试过它。 Hi 设置 哪个容器的时区
Author
Owner

@lanlv1904 commented on GitHub (Jan 23, 2026):

我是dify前端页面和容器中的时间全都修改正常了,但是数据库中写入的时间还是慢了8小时。

@lanlv1904 commented on GitHub (Jan 23, 2026): 我是dify前端页面和容器中的时间全都修改正常了,但是数据库中写入的时间还是慢了8小时。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#747