开发者

Dealing with timezones in Django

I'm trying开发者_Python百科 to deal with timezone information in Django. I tried doing something like:

results = Competitor.objects.raw("SELECT official_start AT TIME ZONE 'UTC', official_finish AT TIME ZONE 'UTC' FROM competitor WHERE race_id=1")

Thinking that this way I would know that the timezone was UTC but say I store a time in the database that is '2010-07-30 15:11:23' in UTC, in Django it will show up as '2010-07-30 10:11:23'. Any idea what is going on?


I realized that in the settings.py file there is an option: TIME_ZONE. setting this to UTC solved the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜