Reputation: 52932
I have this format string "YYYY-MM-dd HH:mm:ss"
I have this date: "2013-08-28 15:01:17"
And this is my code:
DateTime.TryParseExact(fromString, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out outDateTime);
However it returns false indicating it failed to parse.
I'm not really sure why, any ideas?
Upvotes: 2
Views: 152
Reputation: 148990
YYYY
is not a valid format specifier (it would be parsed as a literal YYYY
). Use lowercase y
's in your format string instead:
yyyy-MM-dd HH:mm:ss
Further Reading
Upvotes: 6