开发者

Dealing with timezones in Django

开发者 https://www.devze.com 2023-01-09 19:47 出处:网络
I\'m trying开发者_Python百科 to deal with timezone information in Django. I tried doing something like:

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

精彩评论

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

关注公众号