You are viewing a single comment's thread. Return to all comments →
C# without using DateTime:
public static string timeConversion(string s) { bool isPM = s.Substring(8, 2) == "PM"; string hourFormat = s.Substring(0, 8); int hour = int.Parse(hourFormat.Substring(0, 2)); hourFormat = hourFormat.Remove(0, 2); if (!isPM) { if(hour == 12) return "00" + hourFormat; return hour < 9 ? "0" + hour + hourFormat : hour + hourFormat; } hour = hour == 12 ? hour : hour + 12; return hour + hourFormat; }
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 →
C# without using DateTime: