How to set the timezone in Django?

后端 未结 8 885
萌比男神i
萌比男神i 2020-11-29 19:33

In my django project\'s settings.py file, I have this line :

TIME_ZONE = \'UTC\'

But I want my app to run in UTC+2 timezone, s

相关标签:
8条回答
  • 2020-11-29 20:19

    I found this question looking to change the timezone in my Django project's settings.py file to the United Kingdom.

    Using the tz database in jfs' solution I found the answer:

        TIME_ZONE = 'Europe/London'
    
    0 讨论(0)
  • 2020-11-29 20:23

    Universal solution, based on Django's TZ name support:

    UTC-2 = 'Etc/GMT+2'
    UTC-1 = 'Etc/GMT+1'
    UTC = 'Etc/GMT+0'
    UTC+1 = 'Etc/GMT-1'
    UTC+2 = 'Etc/GMT-2'
    

    +/- is intentionally switched.

    0 讨论(0)
提交回复
热议问题