Django: changing timezone

154 Views Asked by At

I have following code in my django shell :

>>> import datetime
>>> import pytz
>>> p = pytz.timezone("Asia/Kolkata")
>>> pt = p.localize(datetime.datetime(2012,3,3,1,30))
>>> pt.date()
datetime.date(2012, 3, 3)
>>> pt.tzinfo
<DstTzInfo 'Asia/Kolkata' IST+5:30:00 STD>
>>> pt = p.localize(datetime.datetime.now())
>>> pt.date()
datetime.date(2014, 12, 17)
>>> pt.time()
datetime.time(19, 7, 55, 432350)
>>> pt.tzinfo
<DstTzInfo 'Asia/Kolkata' IST+5:30:00 STD>
>>> pt
datetime.datetime(2014, 12, 17, 19, 7, 55, 432350, tzinfo=<DstTzInfo 'Asia/Kolkata' IST+5:30:00 STD>)

But the time shown in last output is : 2014, 12, 17, 19, 7, 55, 432350, tzinfo=<DstTzInfo 'Asia/Kolkata' IST+5:30:00 STD> but the time time here doesnot match with the set timezone. What is happening here?

0

There are 0 best solutions below