IsDate

public static bool IsDate(this string input)
{
    if (!string.IsNullOrEmpty(input))
    {
        DateTime dt;
        return (DateTime.TryParse(input, out dt));
    }
    else
    {
        return false;
    }
}
Example:
string nonDate = "Foo";
string someDate = "Jan 1 2010";

bool isDate = nonDate.IsDate(); //false
isDate = someDate.IsDate(); //true

Description

Wraps DateTime.TryParse() and all the other kinds of code you need to determine if a given string holds a value that can be converted into a DateTime object.

Details

Double click on the code to select all.

 

;