I've a problem with DateTime TryParseExact.
I need to parse a string date in this format : "10 Fri, Jun 2013"
My pattern is : "d ddd, MMM yyyy"
Look at the code bellow
private static readonly string[] EnglishFormats =
{
"yyyy-MM-ddTHH:mm:sszzz", "dd MMMM yyyy HH:mm" , "dddd, MMMM d, yyyy","dddd, d MMMM yyyy","dddd, MMMM d, yy","dddd, d MMMM yy","d ddd, MMM yyyy"
};
public static bool TryParseEnglishDate(string s, out DateTime result)
{
return DateTime.TryParseExact(s, EnglishFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out result);
}
When s = "10 Fri, Jan 2014" that works ==> result = 1/10/2014 12:00:00 AM
When s = "10 Fri, Jan 2013" or other years it doesn't work ==> result= "1/1/0001 12:00:00 AM"
Have you got an idea why it doesn't work with differents year than 2014 ?
Thanks