Given a time in 12-hour AM/PM format, convert it to military (24-hour) time.
Note: Midnight is 12:00:00 AM on a 12-hour clock and 00:00:00 on a 24-hour clock. Noon is 12:00:00 PM on 12-hour clock and 12:00:00 on 24-hour clock
Input : A single string containing a time in 12-hour clock format(hh:mm:ss AM or hh:mm:ss PM where 01 <= hh <= 12 or 01 <= mm,ss <= 59 Output :Convert and print the given time in 24-hour format, where 00 <= hh <= 23 Input : 07:05:45PM Output : 19:05:45
This article is contributed by Rahul singh (Nit kkr). If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Python program to convert time from 12 hour to 24 hour format
- Convert time from 24 hour clock to 12 hour clock format
- Find time when hour and minute hands superimpose
- Find a time for which angle between hour and minute hands is given theta
- Time when minute hand and hour hand coincide
- Hour-glass Pattern
- Program to Convert Milliseconds to a Date Format in Java
- Program to find the time after K minutes from given time
- Convert given time into words
- Convert timestamp to readable date/time in PHP
- Convert C/C++ program to Preprocessor code
- Program to Convert Radian to Degree
- Program to convert Degree to Radian
- Python Program to convert Kilometers to Miles
- Program to convert KiloBytes to Bytes and Bits
- Program to Convert Km/hr to miles/hr and vice versa
- Program to Convert Hexadecimal Number to Binary
- Program to convert Centimeter to Feet and Inches
- Program to convert speed in km/hr to m/sec and vice versa
- Program to convert centimeter into meter and kilometer
Improved By : Rajput-Ji