String.Format DateTime value in decreasing number format c#?
Date开发者_如何转开发Time input = DateTime.Now; //06/02/2011 04:05:07 PM
expectedOutput string = "20110602040507";
I want to get the above output string based on date following this ( year,month,day,hour,minute,second) pattern.
You need the format string "yyyyMMddHHmmss", which will give hours in 24-hour format.
DateTime.Now.ToString("yyyyMMddHHmmss");
Use DateTime.ToString method:
String format = "yyyyMMddHHmmss";
String formattedValue = input.ToString(format);
精彩评论