Using
DateTime.Parse method ,we can check whether string is a valid date or not.If string date is valid,then it will return True otherwise return False.
public bool IsDate(this string astrText)
{
try
{
System.DateTime dtDateTime = System.DateTime.Parse(astrText);
}
catch
{
return false;
}
return true;
}