如何更改我的Django服务器时间 [英] How to change my django server time

查看:116
本文介绍了如何更改我的Django服务器时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将当前日期保存在数据库中,但是我的Django服务器比当前时间早13小时启动。因此,当我使用以下命令时,时间也在改变:

I want to save the present date in database, but my Django server starting 13 hours earlier than the present time. Due to this the time is also changing when I use the following:

datetime.datetime.now()

我正在将Python 2.7.5与Django 1.5.4结合使用。
如何显示 django 的当前系统日期??

I am using Python 2.7.5 with Django 1.5.4. How can I display my present system date with django..?

推荐答案

如果服务器日期和时间错误,请尝试首先解决该问题。如果它们是正确的,则可以在 settings.py 中添加时区值:

If your server date and time is wrong, try to fix that first. If they are correct, you can add a timezone value into your settings.py:

USE_TZ = True
TIME_ZONE = 'UTC'

检查http://en.wikipedia.org/wiki/List_of_tz_database_time_zones 以获得有效时区列表。

Check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of valid time zones.

这篇关于如何更改我的Django服务器时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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