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

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

问题描述

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

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

TIME_ZONE = 'UTC'

但我希望我的应用在 UTC+2 时区运行,所以我将其更改为

But I want my app to run in UTC+2 timezone, so I changed it to

TIME_ZONE = 'UTC+2'

它给出了错误 ValueError: Incorrect timezone setting: UTC+2.这样做的正确方法是什么?

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

谢谢!

推荐答案

以下是有效时区列表:

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

你可以使用

TIME_ZONE = 'Europe/Istanbul'

对于 UTC+02:00

for UTC+02:00

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

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