The below code gives error.
CultureInfo ci = CultureInfo.InvariantCulture;
string archTime = "7/25/2012 11:26:22 AM";
DateTime dt1 = DateTime.ParseExact(archTime, "MM/dd/yyyy hh:mm", ci);
Exception message is
String was not recognized as a valid DateTime.
Error in conversion
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Atul KumarRank #1,527 · 1K reputationPosted Jul 25, 2012, 10:21 PM EDT
CultureInfo ci = CultureInfo.InvariantCulture;
string archTime = "7/25/2012 11:26:22 AM";
DateTime dt1 = DateTime.ParseExact(archTime, "M/dd/yyyy HH:mm:ss tt", ci); //changed format
your datetime format is not correct.