I want to convert date DD-MM-YYYY into default format of date time "MM/DD/YYYY" in C#.
is there string format which helps me to d开发者_如何学Co.
(DateTime.ParseExact(input, "dd-MM-yyyy", CultureInfo.InvarientCulture).ToString("MM/dd/yyyy")
(Not assuming any defaults – "mm/dd/yyyy" is not the default date format for most people.)
Try This
DateTime dt = GetDate(DateStringToConvert);
dt.ToString("MM/dd/yyyy");
string oldstr = "03/12/2011";
string strDate = DateTime.ParseExact(oldstr, "dd/MM/yyyy",null).ToString("MM/dd/yyyy");
Console.WriteLine(strDate);
精彩评论