Why does my call to DateTime.TryParseExact fail?

.net, datetime

Solution

The time you are passing in is 24-hour time (the hour component is 13).

You need to use HH instead of hh to get 24 hour time.

Here is a useful MSDN page on all the time format strings: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

Problem

Simple question: I call: ``` DateTime.TryParseExact("May 16 13:47:12 2012", "MMM dd hh:mm:ss yyyy", System.Globalization.CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.None, out parsedStartDate) ``` and the result is false. Why did I do wrong?

Original source