You are viewing a single comment's thread. Return to all comments →
My solution for C#.Net. It works for all testcases.
public static string timeConversion(string s) { DateTime dt; string result = ""; string meridian = s.Substring(8,2); if(DateTime.TryParse(s.Substring(0,8), out dt)) { if(dt.Hour == 12 && meridian == "AM") { result = dt.AddHours(-12).ToString(); } else if(dt.Hour != 12 && meridian == "PM") { result = dt.AddHours(12).ToString(); } else { result = dt.ToString(); } } return result.Substring(11,8); }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
My solution for C#.Net. It works for all testcases.