On 25/06/2014 7:44 AM, Jerry Wu wrote:> 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?
My settings uses Australia/Melbourne and Postgres stores time correctly
as UTC+10 (or UTC+11 in daylight saving time).
But as it happens I'm in New Zealand for a couple of days. So I'll
change my laptop location to Wellington tonight and log in and create
some test entries and knowing when I do that I should be able to check
the results after switching the laptop back to Melbourne time.
Now I think of it I could pretend I'm in Shanghai :)
You can see from the above that I half-believe pytz uses the system
locale to figure out the UTC offset. But I suppose it might be TIME_ZONE
in settings.
Have to go out now. I'll report back later
Mike
>
>
> 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/
> <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
>
> <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+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/09843c1de23868d2d8fe13160e054aea%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment