I was experiencing the DateTime error as "string was not recognized as a valid datetime" with the below code.
string createdAt = "12-08-2015 10:35:41";
string formatDate = "MM-DD-YYYY HH:mm:Ss";
CultureInfo provider = CultureInfo.InvariantCulture;
onSetDate = DateTime.ParseExact(createdAt , formatDate, provider);
Can some advise me on this?