To convert string into DateTime you can use Convert.ToDateTime function in C# ASP.Net 2.0. Further you can also format the output of Date or Time.
DateTime Format Examples:
You can see the live samples and examples of C# DateTime format from the following links:
First of all create a string variable to store the string type DateTime.
string myDateTimeString;
Then create a new variable of type DateTime and pass the string to DateTime variable using Convert.ToDateTime function.
DateTime dt;
dt = Convert.ToDateTime(myDateTimeString);
Now you are ready to get the different parts of the Date String passed to the DateTime variable.
Response.Write(dt.Day + "/" + dt.Month + "/" + dt.Year);
Complete C# code to convert string to DateTime:
string myDateTimeString;
myDateTimeString = "19 Feb,2008";
DateTime dt;dt = Convert.ToDateTime(myDateTimeString);
Response.Write(dt.Day + "/" + dt.Month + "/" + dt.Year);
Output: 19/2/2008
Further you can format the DateTime using ToString("xxxxxx").
Learn DateTime ToString Formats here C# Date Format using ToString function.
Continue to next tutorial: ASP.Net 2.0 C# DateTime IFormatProvider Using ParseExact to learn culture based DateTime string conversion to DateTime object.