Forums

Wrong timezone time

Hi, I am using following code to retrieve time according to my timezone: <br>

tz = timezone('Asia/Calcutta')
x = pytz.utc.localize(datetime.now(), is_dst=None).astimezone(tz)
print('@@@SCHEDULER -  hour, miute, weekday -- ' + str(x.hour) +  " " + str(x.minute) +  "  " +str(x.weekday ()))

At 15:05 IST, the returned value is : @@@SCHEDULER - hour, miute, weekday -- 20 35 0

which ideally should be 15:05, the same code used to work a few days back. What has happened to PA ?

Solved in email: datetime.now() was returning a datetime in local time to the user.