0

How to convert a 12hr format to 24 hr format using c function.

4th Feb 2023, 2:04 PM
Durjoy Kumar Saha
2 Respuestas
+ 3
You first need to know whether it was AM or PM cause it's in 12 hour format. Basically, you add 12 to the hour when it was PM. Example 02:00 PM in 12 hour format is 14:00 in 24 hpur format. 12 hours was added to the original hour.
4th Feb 2023, 2:55 PM
Ipang
+ 3
Durjoy Kumar Saha you can use the function, strftime() and %H format specifier. It requires #include <time.h>.
5th Feb 2023, 2:00 AM
Brian
Brian - avatar