Skip to main content
Jun 16, 2013
/// <summary>
/// Method checks if passed string is datetime
/// </summary>
/// <param name="text">string text for checking</param>
/// <returns>bool - if text is datetime return true, else return false</returns>
public bool IsDateTime(string text)
{
	DateTime dateTime;
	bool isDateTime = false;

	// Check for empty string.
	if (string.IsNullOrEmpty(text))
	{
		return false;
	}

	isDateTime = DateTime.TryParse(text, out dateTime);

	return isDateTime;
}