开发者

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);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜