0

This is my code using this i am converting my time to in utc time :

pickup_time = "03:00 PM"

local_time = pytz.timezone("Asia/Kolkata")
naive_datetime = datetime.datetime.strptime (pickup_time, "%I:%M %p")
local_datetime = local_time.localize(naive_datetime, is_dst=None)
utc_datetime = local_datetime.astimezone(pytz.utc)
print(utc_datetime)
print(utc_datetime.strftime("%I:%M %p"))

In result i am getting like :

1900-01-01 09:07:00+00:00

09:07 AM

but according to me it should be 09:30 AM .in IST offset of UTC+05:30 but i am getting 6 hours. can anyone please suggest me what i am doing wrong here .

Preety Joshi
  • 31
  • 1
  • 6

1 Answers1

0

You can change the settings.py like this, there is no need for this mess

TIME_ZONE = 'Asia/Kolkata'

You can read more here

Aditya Komawar
  • 61
  • 1
  • 1
  • 6