[Solved] Time string to a different DateTime format in c# [closed]
Assuming timeDeparture.Text has Format h:mm tt like 9:10 pm, you have to parse it first into DateTime and use .ToString() to bring it into the desired 24h format. In .NET h is for 12h format and H represents 24h format. string timeDeparture = “10:30 PM”; DateTime parsedResult = DateTime.ParseExact(timeDeparture, “h:mm tt”, System.Globalization.CultureInfo.InvariantCulture); string result = … Read more