Converting dd/MM/yyyy string format date to MM/dd/yyyy date format in ASP.NET Mvc
我想把
但我想将
请帮帮我!
试试这个
1 2 | DateTime dateTime = new DateTime(); dateTime = Convert.ToDateTime(DateTime.ParseExact("YouDateString","MM/dd/yyyy", CultureInfo.InvariantCulture)); |
首先使用
1 2 3 | string inp ="23/08/2016"; // inp is dd/MM/yyyy format date string DateTime date = DateTime.ParseExact(inp,"dd/MM/yyyy", CultureInfo.InvariantCulture); string s1 = date.ToString("MM/dd/yyyy"); // s1 is now MM/dd/yyyy format date string |
或者只是一个表达
1 | string s2 = DateTime.ParseExact("23/08/2016","dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy"); |
号