I’m trying to parse the following UK format DateTime string: 24/01/2013 22:00
However, I keep getting this error:
String was not recognized as a valid DateTime.
CultureInfo.CurrentCulture returns “en-GB” which is correct
Here is my code
[TestMethod]
public void TestDateTimeParse()
{
DateTime tester = DateTime.ParseExact("24/01/2013 22:00", "d/M/yyyy hh:mm", CultureInfo.CurrentCulture);
int hours = tester.Hour;
int minutes = tester.Minute;
Assert.IsTrue(true);
}
hhis for 12 hour clocks. You should be usingHHinstead.