Time zone setting is invalid, interface displays time issue #11994

Closed
opened 2026-02-21 19:05:10 -05:00 by yindo · 7 comments
Owner

Originally created by @AlexKuai on GitHub (Mar 23, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  • My configuration

    • docker-compose.yaml
    api:
        environment:
          TZ: Asia/Shanghai
        volumes:
          - /etc/localtime:/etc/localtime:ro   # Mount local host time
    worker:
        environment:
          TZ: Asia/Shanghai
        volumes:
          - /etc/localtime:/etc/localtime:ro  # Mount local host time
    web:
        environment:
          TZ: Asia/Shanghai
        volumes:
          - /etc/localtime:/etc/localtime:ro  # Mount local host time
    
    • .env
    LOG_TZ=Asia/Shanghai
    
  • problem

Through the above configuration, the display time on my interface is still 8 hours ahead of the current local time. The following is a screenshot of what was displayed after I just logged in.

Image

But the logs and time entering the container are consistent with the local host time.

Image

Image

✔️ Expected Behavior

Display the correct time zone and time

Actual Behavior

The time is not in the current time zone

Originally created by @AlexKuai on GitHub (Mar 23, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce - My configuration - docker-compose.yaml ```yaml api: environment: TZ: Asia/Shanghai volumes: - /etc/localtime:/etc/localtime:ro # Mount local host time worker: environment: TZ: Asia/Shanghai volumes: - /etc/localtime:/etc/localtime:ro # Mount local host time web: environment: TZ: Asia/Shanghai volumes: - /etc/localtime:/etc/localtime:ro # Mount local host time ``` - .env ```ini LOG_TZ=Asia/Shanghai ``` - problem Through the above configuration, the display time on my interface is still 8 hours ahead of the current local time. The following is a screenshot of what was displayed after I just logged in. ![Image](https://github.com/user-attachments/assets/ef3b99c3-99a9-4940-8a9c-7279fa3ab41d) But the logs and time entering the container are consistent with the local host time. ![Image](https://github.com/user-attachments/assets/5a327193-803c-4212-90a9-df54af8704ce) ![Image](https://github.com/user-attachments/assets/1a7bdac2-a347-4e09-8093-bd991772a7a8) ### ✔️ Expected Behavior Display the correct time zone and time ### ❌ Actual Behavior The time is not in the current time zone
yindo added the 🐞 bug label 2026-02-21 19:05:10 -05:00
yindo closed this issue 2026-02-21 19:05:10 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 23, 2025):

Hey @AlexKuai! 👋 I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let's squash those bugs together!

I found some similar discussions that might be relevant to your issue:

  1. The time for logs within the application is not UTC+8 - This discussion is still open and might provide insights into similar time zone issues [1].

  2. How to modify the time zone of diffy using docker deployment - This is another open discussion that could be helpful for Docker-specific time zone configurations [2].

Regarding your issue, it seems that despite setting the TZ environment variable and mounting /etc/localtime, the interface time is still incorrect. This might be due to Dify's internal handling of time zones. In the Dify codebase, the ext_timezone.py file sets the environment variable TZ to "UTC", which could override your Docker settings [3].

You might want to check if the init_app function in ext_timezone.py is being executed and overriding your settings. If so, you could try modifying this file to respect the TZ environment variable set in your Docker configuration.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Mar 23, 2025): <!-- Greeting --> Hey @AlexKuai! 👋 I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let's squash those bugs together! <!-- Answer --> I found some similar discussions that might be relevant to your issue: 1. [The time for logs within the application is not UTC+8](https://github.com/langgenius/dify/discussions/16440) - This discussion is still open and might provide insights into similar time zone issues <sup>[[1]](https://github.com/langgenius/dify/discussions/16440)</sup>. 2. [How to modify the time zone of diffy using docker deployment](https://github.com/langgenius/dify/discussions/7776) - This is another open discussion that could be helpful for Docker-specific time zone configurations <sup>[[2]](https://github.com/langgenius/dify/discussions/7776)</sup>. Regarding your issue, it seems that despite setting the `TZ` environment variable and mounting `/etc/localtime`, the interface time is still incorrect. This might be due to Dify's internal handling of time zones. In the Dify codebase, the `ext_timezone.py` file sets the environment variable `TZ` to "UTC", which could override your Docker settings <sup>[[3]](https://github.com/langgenius/dify/blob/main/api/extensions/ext_timezone.py)</sup>. You might want to check if the `init_app` function in `ext_timezone.py` is being executed and overriding your settings. If so, you could try modifying this file to respect the `TZ` environment variable set in your Docker configuration. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f107b10c-c91e-4637-abde-32aa9516becc?feedback_type=other)</sup>
Author
Owner

@huu3301 commented on GitHub (Mar 25, 2025):

In version v1.1.3, I encountered a similar problem. The time shown in the log is 12 hours earlier than the actual time.
The value of LOG_TZ was set to Asia/Shanghai.

Image

@dosu

@huu3301 commented on GitHub (Mar 25, 2025): In version v1.1.3, I encountered a similar problem. The time shown in the log is 12 hours earlier than the actual time. The value of LOG_TZ was set to Asia/Shanghai. ![Image](https://github.com/user-attachments/assets/8af4a29a-96fc-4aae-bca6-0eee29c08686) @dosu
Author
Owner

@weikangli commented on GitHub (Apr 10, 2025):

#16440

@weikangli commented on GitHub (Apr 10, 2025): #16440
Author
Owner

@IthacaDream commented on GitHub (Apr 14, 2025):

try to change your profile timezone settings
Image

@IthacaDream commented on GitHub (Apr 14, 2025): try to change your profile timezone settings ![Image](https://github.com/user-attachments/assets/cc3a9e7f-ea64-44a3-8607-b145d042d1e0)
Author
Owner

@hemin108 commented on GitHub (Apr 14, 2025):

.env file added
TZ=Asia/Shanghai
LOG_TZ=Asia/Shanghai
then
1、system time is ok.
2、app log time is ok.
3、time in db table was changed to UTC.
4、the time on web page is not ok.
the time before save in db was changed to UTC but this method 'TimezoneConversionTool.timezone_convert' add source time zone on this time is wrong. b

@hemin108 commented on GitHub (Apr 14, 2025): .env file added TZ=Asia/Shanghai LOG_TZ=Asia/Shanghai then 1、system time is ok. 2、app log time is ok. 3、time in db table was changed to UTC. 4、the time on web page is not ok. the time before save in db was changed to UTC but this method 'TimezoneConversionTool.timezone_convert' add source time zone on this time is wrong. b
Author
Owner

@dataknocker commented on GitHub (Apr 18, 2025):

@hemin108 this way is ok for me:
1、remove volumns /etc/localtime:/etc/localtime in dify-api and dify-worker,then web time is ok。
2、add environment TZ and LOG_TZ in dify-api and dify-worker,then log is ok。

@dataknocker commented on GitHub (Apr 18, 2025): @hemin108 this way is ok for me: 1、remove volumns /etc/localtime:/etc/localtime in dify-api and dify-worker,then web time is ok。 2、add environment TZ and LOG_TZ in dify-api and dify-worker,then log is ok。
Author
Owner

@SomaLily commented on GitHub (Aug 6, 2025):

TZ=Asia/Shanghai
LOG_TZ=Asia/Shanghai

only set LOG_TZ is ok. TZ should be set in website Settings.

@SomaLily commented on GitHub (Aug 6, 2025): > TZ=Asia/Shanghai > LOG_TZ=Asia/Shanghai only set LOG_TZ is ok. TZ should be set in website Settings.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#11994