如何在Django中设置时区? [英] How to set the timezone in Django?

查看:160
本文介绍了如何在Django中设置时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的django项目的 settings.py 文件中,我有这样一行:

  TIME_ZONE ='UTC'

但是我希望我的应用程序以UTC + 2时区,所以我更改为

  TIME_ZONE ='UTC + 2'
pre>

它给出错误 ValueError:时区设置不正确:UTC + 2 。这样做的正确方法是什么?



谢谢!

解决方案

以下是有效时区的列表:



http:// en。 wikipedia.org/wiki/List_of_tz_database_time_zones



您可以使用

  TIME_ZONE ='欧洲/伊斯坦布尔'

为UTC + 02:00


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, so I changed it to

TIME_ZONE = 'UTC+2'

It gives the error ValueError: Incorrect timezone setting: UTC+2. What is the correct way of doing this?

Thanks!

解决方案

Here is the list of valid timezones:

http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

You can use

TIME_ZONE = 'Europe/Istanbul'

for UTC+02:00

这篇关于如何在Django中设置时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆