How to set the timezone in Django?

后端 未结 8 890
萌比男神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:07

    Valid timeZone values are based on the tz (timezone) database used by Linux and other Unix systems. The values are strings (xsd:string) in the form “Area/Location,” in which:

    Area is a continent or ocean name. Area currently includes:

    • Africa
    • America (both North America and South America)
    • Antarctica
    • Arctic
    • Asia
    • Atlantic
    • Australia
    • Europe
    • Etc (administrative zone. For example, “Etc/UTC” represents Coordinated Universal Time.)
    • Indian
    • Pacific

    Location is the city, island, or other regional name.

    The zone names and output abbreviations adhere to POSIX (portable operating system interface) UNIX conventions, which uses positive (+) signs west of Greenwich and negative (-) signs east of Greenwich, which is the opposite of what is generally expected. For example, “Etc/GMT+4” corresponds to 4 hours behind UTC (that is, west of Greenwich) rather than 4 hours ahead of UTC (Coordinated Universal Time) (east of Greenwich).

    Here is a list all valid timezones

    You can change time zone in your settings.py as follows

    LANGUAGE_CODE = 'en-us'
    
    TIME_ZONE = 'Asia/Kolkata'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    

提交回复
热议问题