Skip to content

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

Closed
@fisherzrj

Description

@fisherzrj

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

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

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions