Suppose I have date string like mydate = "24-Jun-2011";
I want to convert it to another format "2011开发者_JAVA百科-06-24". What is the simple way to do this?The best way is to parse the string to a DateTime and then convert it to a string again.
Be sure to have a look at the documentation for DateTime.Parse, DateTime.TryParse and DateTime.ToString
DateTime.Parse(myDate).ToString("yyyy-MM-dd");
DateTime.ParseExact("24-Jun-2011", "dd-MMM-yyyy").ToString ("yyyy-MM-dd")
See formats here at MSDN.
U can Parse
it to DateTime
and then using tostring
+ special format get what u need
http://www.csharp-examples.net/string-format-datetime/ has a lot of different formatting options... This should work well for you.
精彩评论