Как насчет этого?
var @return = (DateTime?)null;
if (source != null)
{
source = source.Trim();
if (source.Length > 0)
{
var fs = new string[]
{
"d MMMM yyyy h:mm tt",
"d MMMM yyyy h:mm:ss tt",
"d MMMM yyyy HH:mm",
"d MMMM yyyy HH:mm:ss",
"d MMMM yyyy",
"d/M/yy h:mm tt",
"d/M/yy h:mm:ss tt",
"d/M/yy HH:mm",
"d/M/yy HH:mm:ss",
"d/M/yy",
"d/M/yyyy HH:mm",
"d/M/yyyy HH:mm:ss",
"d/M/yyyy h:mm:ss tt",
"d/M/yyyy",
"d/M/yyyy h:mm tt",
"d-MMMM-yy HH:mm",
"d-MMMM-yyyy h:mm tt",
"d-MMMM-yyyy h:mm:ss tt",
"d-MMMM-yyyy HH:mm",
"d-MMMM-yyyy HH:mm:ss",
"d-MMMM-yyyy",
"d-MMM-yy",
"d-MMM-yy h:mm tt",
"d-MMM-yy h:mm:ss tt",
"d-MMM-yy HH:mm",
"d-MMM-yy HH:mm:ss",
"d-MMM-yyyy",
"d-M-yy h:mm tt",
"d-M-yy h:mm:ss tt",
"d-M-yy HH:mm",
"d-M-yy HH:mm:ss",
"d-M-yy",
"d-M-yyyy",
"yyyy/M/d h:mm tt",
"yyyy/M/d h:mm:ss tt",
"yyyy/M/d HH:mm",
"yyyy/M/d HH:mm:ss",
"yyyy/M/d",
"yyyy-M-d h:mm tt",
"yyyy-M-d h:mm:ss tt",
"yyyy-M-d HH:mm",
"yyyy-M-d HH:mm:ss",
"yyyy-M-d",
"yyyy-MM-ddTHH:mm:ss",
};
@return = DateTime.ParseExact(source, fs,
System.Globalization.CultureInfo.CurrentCulture,
System.Globalization.DateTimeStyles.None);
}
}
return @return;