Thanks, Mike.
I still have a question. In your code, which part should I change in order to set the time zone to Asia/Shanghai?
On Tuesday, June 24, 2014 7:26:52 AM UTC+8, Mike Dewhirst wrote:
On 24/06/2014 8:34 AM, Jerry Wu wrote:
> Dear every one,
>
> I am following the tutorial
> <https://docs.djangoproject.com/en/1.6/intro/tutorial01/ > 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
> <https://docs.djangoproject.com/en/1.6/ref/settings/#std: >setting-TIME_ZONE
> in the tutorial.
This a very good question. Especially considering the variability
between databases. At least I think so - I use Postgres and that seems
to store times in UTC. In my case it is accidentally just what I want so
I'm not changing anything.
But just in case, I use the following utility everywhere ...
import pytz
from datetime import datetime
def when():
return datetime.now(tz=pytz.utc)
I wish I understood (or had the time and brainspace to commit to memory)
exactly how it all works. I think the target audience for the
documentation is somewhat smarter than I.
Mike
>
> 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...@googlegroups.com
> <mailto:django-users+unsubscribe@googlegroups.com >.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@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/fcda6aed- 87ee-48f6-85d8-2b2906056b81% 40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fcda6aed- >.87ee-48f6-85d8-2b2906056b81% 40googlegroups.com?utm_medium= email&utm_source=footer
> For more options, visit https://groups.google.com/d/optout .
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/ad37ab7a-3ae6-4071-8043-a40723b10036%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment