C # noob here. A simple question, but looking at everything online, I seem to be doing it right. But can anyone tell me why this code is not working:
string testDateString = "2/02/2011 3:04:01 PM"; string testFormat = "d/MM/yyyy h:mm:ss tt"; DateTime testDate = new DateTime(); DateTime.TryParseExact(testDateString, testFormat, null, 0, out testDate);
But just remove AM / PM from the string date, and does "tt" from the format work as expected?
string testDateString = "2/02/2011 3:04:01"; string testFormat = "d/MM/yyyy h:mm:ss"; DateTime testDate = new DateTime(); DateTime.TryParseExact(testDateString, testFormat, null, 0, out testDate);
Aaryn
source share