Wednesday, June 25, 2014

Re: Time Zone Problem when following on tutorial

Jerry

I just figured it out and it is simple. Time is constant and all you need to do is decide how* you want to display it. The TIME_ZONE setting tells the server.

An event happens at the same time everywhere in the universe (there may be Einsteinian exceptions to this) and you can store that time in the database relative to UTC. If you choose Shanghai time in settings then all recorded times are stored/displayed as Shanghai time. That is totally fair. People elsewhere just need to know the system is runing on "Shanghai time"

I don't know why it was necessary to switch the Django default to UTC except that lots of people use and can think in UTC as well as local time. The entire aviation industry for example. There may be a tiny performance gain avoiding calculating a local time.

The backwards compatibility thing is vital because if you have history in your database you can't just switch the base from UTC+8 to UTC without making all the stored times invalid by 8 hours.

What do you think?

Mike

On Tuesday, June 24, 2014 10:34:03 AM UTC+12, Jerry Wu wrote:
Dear every one,

I am following the tutorial and meet with some problem with Time Zone part. Since I am in Shanghai, China (UTC+8) , I think it is necessary to reset the time part.

Below is what I tried but failed with valuerror incorrect timezone setting:

TIME_ZONE="UTC+8"
TIME_ZONE="UTC+8:00"

I have tried "Asia/Shanghai", it works, but I think it is kind of out-of-date style due to the description in the tutorial.

Could some one give me a hint?

Thans in advance.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/52170bc7-e4f2-4664-94b6-8cbdd028b31b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment