Answers for "how to convert 24 hours to 12 hours in python"

0

how to convert 24 hours to 12 hours in python

from datetime import datetime
d = datetime.strptime("10:30", "%H:%M")
print(d.strftime("%I:%M %p")) # outputs '10:30 AM'
d = datetime.strptime("22:30", "%H:%M")
print(d.strftime("%I:%M %p")) # outputs'10:30 PM'
Posted by: Guest on June-02-2021

Code answers related to "how to convert 24 hours to 12 hours in python"

Python Answers by Framework

Browse Popular Code Answers by Language