How to convert a date string “dd/MM/yyyy” format into “MM/dd/yyyy” in asp.net c#?

前端 未结 4 1400
自闭症患者
自闭症患者 2021-01-13 11:10

I want to convert a string date formate \"dd/MM/yyyy\" into \"MM/dd/yyyy\" in c# example

 string d =\"25/02/2012\";  i want to convert into 02/25/2012
         


        
4条回答
  •  花落未央
    2021-01-13 11:37

    Try this:

    string d ="25/02/2012";  
    DateTime dtReturn = DateTime.MinValue;
    
    DateTime.TryParseExact(d , "dd/MM/yyyy", dateFormat,
    DateTimeStyles.AllowWhiteSpaces, out dtReturn)
    

    will Return "2/25/2012 12:00:00 AM"

提交回复
热议问题