I have a string like below
1/1/1970 12:00:00 AM
I want it in the yyyy-MM-dd format (in this case 1970-01-01) My parsing code is
var actualDate = DateTime.ParseExact(actualValue,"MM/dd/yyyy HH:mm:ss tt",CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
But I keep getting the error, that the string is not recognized as a valid date time. I looked at my variable actualValue and it is of type DateTime, so am thinking that the problem is with the format MM/dd/yyyy HH:mm:ss tt ,What is wrong with this?