.net: How to parse a date with this format: 08 Feb 2011 06:46

DateTime.ParseExact("08 Feb 2011 06:46", "dd MMM yyyy hh:mm", 
    System.Globalization.CultureInfo.InvariantCulture);

In your question’s sample code, you forgot to capitalize all of the month “M”s.

Edit

As Anton points out, the “H”s also need to be capitalized to use military time.

DateTime.ParseExact("08 Feb 2011 13:46", "dd MMM yyyy HH:mm", 
    System.Globalization.CultureInfo.InvariantCulture)

The above code works for me. I can’t imagine why you’d get an error on the same code, when we’re specifying the culture. Can you double-check your code and inputs?

Leave a Comment