I have the following string that I need to parse
string date = "2017-06-23T13:45:45.816"
What is correct format string?
I tried
DateTime createDate = DateTime.ParseExact(date, "yyyy-MM-dd'T'hh-mm-ss", CultureInfo.InvariantCulture);
yyyy-MM-dd'T'hh-mm-ss is not 2017-06-23T13:45:45.816 you have missing milliseconds, 12 hour clock and also wrong separators.
yyyy-MM-dd'T'hh-mm-ss
2017-06-23T13:45:45.816
You'd probably need something like:
"yyyy-MM-dd'T'HH:mm:ss.fff"
Remember it's ParseExact.
2.1m questions
2.1m answers
60 comments
57.0k users