I am facing an issue in the parsing of the date. I have made following common function.
public static string ConvertedDate(string date)
{
if(!string.IsNullOrEmpty(date))
{
DateTime returnValue;
bool flag = DateTime.TryParseExact(date, "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out returnValue);
return flag ? returnValue.ToString("MM.dd.yyyy") : null;
}
else
{
return null;
}
}
But very strange thing happens some strings are successfully converted into DateTime but some return false.
For example :
"2017-05-11 12:00:24" this string parse successfully.
"2015-03-06 20:18:42" this string can not.
The format of the string is same.
I observed that when "hour(hh)" goes above 12 then it cannot be parsed.