Created
September 24, 2018 16:09
-
-
Save Timtech4u/45effd93a418c7cfd1012e3253b71a3d to your computer and use it in GitHub Desktop.
12hr to 24hr in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def timeConversion(s): | |
| time = s | |
| if time[-2:] == "AM" and time[:2] == "12": | |
| return "00"+time[2:-2] | |
| elif time[-2:] == "AM": | |
| return time[:-2] | |
| elif time[-2:] == "PM" and time[:2] == "12": | |
| return time[:-2] | |
| else: | |
| return str(int(time[:2]) + 12) + time[2:8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment