Possible Duplicate:
Convert string to datetime Using C#
I want to convert string to DateTime in .NET 2.0
. For example, the string will be in the format like 10/07/2011 (dd/MM/yyyy)
and then I want to convert it to DateTime object.
Possible Duplicate:
Convert string to datetime Using C#
I want to convert string to DateTime in .NET 2.0
. For example, the string will be in the format like 10/07/2011 (dd/MM/yyyy)
and then I want to convert it to DateTime object.
You can parse custom string date formats into a DateTime using DateTime.ParseExact. For example:
var dateTime = DateTime.ParseExact(
"10/07/2011",
"dd/MM/yyyy",
CultureInfo.InvariantCulture);
Or you can specify a culture that has a DMY date format, such as the UK:
var dateTime = DateTime.Parse("13/07/2011", new CultureInfo("en-GB"));
DateTime dt = DateTime.Parse(strdate);