I've got a string in this format:
21-10-2014 15:40:30
I want to make it a DateTime in the format:
2014-10-21 15:40:30
I have tried:
DateTime dt = DateTime.ParseExact("21-10-2014 15:40:30", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
But no luck, it throws an exception String was not recognized as a valid DateTime
EDIT
I have also tried:
DateTime dt = DateTime.ParseExact("21-10-2014 15:40:30", "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);
To have the same format in both parameters. The exception is the same, so the problem isn't a difference between formats. I have checked that before.