开发者

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

开发者 https://www.devze.com 2023-03-21 17:33 出处:网络
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\", CultureI

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

精彩评论

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