开发者

Convert dd-mm-yyyy into mm/dd/yyyyy in C#

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜