-1

In my application, i have two select options. one is for hour selection and another for minute selection. So when i fetch select option values i get values as time string like '12:34'. and I want to convert that time string to UTC time.

So, Can anyone please suggest me that how to get UTC time from timestring?

Thank you.

Nikunj
  • 33
  • 9

1 Answers1

0

You don't have enough information to do that because you need to know the offset of your timezone from UTC.

But to get you started

from datetime import datetime, timedelta
offset = -2 # I live in Central European Summer Time, so I am 2 hours east of UTC
myutctime = datetime.strptime(timestring,'%H:%M') + timedelta(hours=offset)
BoarGules
  • 16,440
  • 2
  • 27
  • 44