When trying to use the parse method on the DateTime class, I get an exception thrown:
String was not recognized as a valid DateTime.
- The string reads as
"26/10/2009 8:47:39 AM"when outputted. - This string is obtained from a group on a match from a regex.
- None of the strings obtained from this match group will parse to datetime.
Examples of other strings:
26/10/2009 8:47:39 AM 26/10/2009 8:00:41 AM 26/10/2009 7:48:35 AM
The weird thing is, I am sure it has worked before.
Parsetakes regional settings (culture of current thread) into account. Therefore, I’d useParseExactand specify the correct format explicitly with an invariant culture (or the culture you need, eg.en-US, for AM/PM).