0

I am trying to convert an unaware datetime to UTC time in Python.

I have:

  • datetime
  • location (latitude and longitude)

I am finding the timezone of my datetime based on the location with

tz.timezone_at(lat=latitude, lng=longitude)

I am now trying to attach this timezone to my datetime to be able to convert it after to UTC. However I am failing at this step.

I have tried:

interview_slot = interview_slot.replace(tzinfo=ZoneInfo(store_timezone))

But unable to import the library that allows me to use ZoneInfo. Do you have another way to do it?

Thank you

Solal
  • 611
  • 2
  • 9
  • 26

1 Answers1

1

Try the answers from this question

Moreover, pytz should be firstly installed from cmd like this: pip install pytz

Ariadne R.
  • 452
  • 11
  • 24