subtract input time from utc time to find offset

Viewed 37

im tryna find the utc offset (example: UTC +02:00) from a user's input time. I only want to do it using hours and minutes and not day/date..

this is my code:

user_time = input("enter hour: " )
utc_time = datetime.datetime.utcnow().strftime("%H%M")
main = int(user_time) - int(utc_time)
print(main)

sometimes it gives a correct output but then it doesnt.. what is the correct way to do this? are they any premade tools to find exactly what i want to do?

0 Answers
Related