Formatting Date String abbreviating month

佐手、 提交于 2019-12-06 02:34:08

问题


I would like to format a standard .NET DateTime string as follows

2014-01-01 => Jan 2014

I can get the date form "January 2014" by using ToString("y") but how can I abbreviate the month?

Is this even possible?

C# Visual Studio 2012 .NET 4.5


回答1:


You can use the MMM format as in:

DateTime.Now.ToString("yyyy-MM-dd => MMM yyyy")

Which produces:

2014-08-06 => Aug 2014



回答2:


You can use "MMM", take a look at this example: http://msdn.microsoft.com/library/zdtaw1bw%28v=vs.110%29.aspx



来源:https://stackoverflow.com/questions/25162808/formatting-date-string-abbreviating-month

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!