Convert a time string from 12-hour format to 24-hour format.
Input format: "hh:mm AM" or "hh:mm PM" (hours may be 1 or 2 digits, e.g., "1:30 PM" or "12:00 AM").
Output format: "HH:MM" in 24-hour time (always 2-digit hours with leading zero if needed).
Rules:
12:00 AM is midnight, which is "00:00" in 24-hour time12:30 PM stays "12:30"1:00 PM becomes "13:00"12:00 PM is noon, which stays "12:00"time = "12:00 AM""00:00"time = "1:30 PM""13:30"time = "12:00 PM""12:00"Input is a valid 12-hour time string in the format "h:mm AM" or "hh:mm AM" (or PM)Hours range from 1 to 12, minutes from 00 to 59Run your code to see results
Use Cmd+Enter to run