分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
DateTime time = DateTime.Now;string s = time.ToString("yyyy.MM.dd hh:mm:ss t\\M");Console.WriteLine(s);
Explanation: t
gives the first character of the AM/PM designator (the localized designator can be retrieved in DateTimeFormatInfo.AMDesignator
and DateTimeFormatInfo.PMDesignator
). The \\M
escapes the M
so that DateTime.ToString
does not interpret it as part of the format string and print the numerical value of the month.
Note that once you do this you are explicitly being culture insensitive. For example, in Japan, the AM/PM designator differs in the second characters, not the first.
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)