答案 0 :(得分:2)
请尝试:
string oldstr = "03/12/2011";
string strDate = DateTime.ParseExact(oldstr, "dd/MM/yyyy",null).ToString("MM/dd/yyyy");
Console.WriteLine(strDate);
答案 1 :(得分:1)
DateTimeFormatInfo usDtfi = new CultureInfo("en-US", false).DateTimeFormat; //--MM/dd/yyyy
DateTimeFormatInfo ukDtfi = new CultureInfo("en-GB", false).DateTimeFormat; //--dd/MM/yyyy
DateTime result = Convert.ToDateTime("07/21/2011", usDtfi); //or: ("21/07/2011", ukDtfi)
然后你有一个DateTime对象(结果)并做你想做的任何事情:
string str = result.ToString("yyyy-MM-dd HH:mm:ss");
快乐编码:)
答案 2 :(得分:1)
试试这个
string DateString = "22/04/2011";
DateTime date = new DateTime();
date = DateTime.ParseExact(DateString, "dd/MM/yyyy");
string NewDateString = date.ToString("MM/dd/yyyy");