0

How to make a program which takes input of time in 12 hrs and converts in 24hrs

the input should be like 05:44:23PM output 17:44:23

10th Mar 2017, 4:21 PM
Prashant Brahmbhatt
Prashant Brahmbhatt - avatar
3 Réponses
+ 4
Console.WriteLine(DateTime.Parse("05:44:23PM").ToString("HH:mm:ss"));
10th Mar 2017, 7:05 PM
HAL8999++;
HAL8999++; - avatar
+ 1
if its PM , add 12 in hours part and for AM leave as it is
10th Mar 2017, 4:37 PM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
+ 1
Be careful with 12h, though! 12am is 0h, and 12pm is 12h... There's no need to add 12 in these cases.
10th Mar 2017, 5:37 PM
Álvaro