I am getting an error when trying to parse a string to datetime.
I have tried this:
string x = "31/5/2012";
DateTime d = DateTime.ParseExact(x, "dd'/'MM'/'yyyy", new CultureInfo("en-US"));
and
string x = "31/5/2012";
DateTime d = DateTime.ParseExact(x, "dd/MM/yyyy", new CultureInfo("en-US"));
and
string x = "31/5/2012";
DateTime d = DateTime.ParseExact(x, "dd/MM/yyyy", cultureinfo.invariantculture));
but I’m still getting the same error.
What do I need to do?
Since your string date has month as
5not05, use singleM