DateTime.ParseExact() does not grok 24-hour time values?

“hh” is the 12-hour clock format (01 to 12). You need to use “HH” for a 24 hour clock.

DateTime dt = DateTime.ParseExact(time, "HH:mm", CultureInfo.InvariantCulture);

Leave a Comment