I have a string containing the date and time
string startDate = "30-09-2022 09:00:00";
DateTime startdate = DateTime.ParseExact(startDate,
"dd/MM/yyyy HH:mm:ss",
CultureInfo.InvariantCulture);
I want to convert to DateTime
, but it doesn't work and the error message is:
System.FormatException: String '30-09-2022 09:00:00' was not recognized as a valid DateTime
How to solve it?
Note: the string is in 24-hour format