My server is located in London.
In my settings.py
I have:
TIME_ZONE = 'Europe/Moscow'
USE_TZ = True
But when I execute this:
from django.utils import timezone
print timezone.now().hour
the code prints London's time. What am I doing wrong?
UPDATE:
>> timezone.now()
datetime.datetime(2013, 4, 16, 12, 28, 52, 797923, tzinfo=<UTC>)
Interesting... tzinfo = <UTC>
. So maybe it prints not a London time, but UTC's +0 time? Anyway, is there any way to make Django show Moscow time?
Also when I render template with now = timezone.now()
{{ now.hour }}
prints 12 (London time)
{{ now|date:"G" }}
prints 16 (Moscow time)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…