格式化日期字符串缩写月份 [英] Formatting Date String abbreviating month
本文介绍了格式化日期字符串缩写月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按如下格式格式化标准.NET DateTime
字符串
I would like to format a standard .NET DateTime
string as follows
2014-01-01 => 2014年1月
2014-01-01 => Jan 2014
我可以使用ToString("y")
来获取日期表格"2014年1月",但是我该如何缩写月份?
I can get the date form "January 2014" by using ToString("y")
but how can I abbreviate the month?
这有可能吗?
C# Visual Studio 2012 .NET 4.5
C# Visual Studio 2012 .NET 4.5
推荐答案
您可以使用MMM
格式,如下所示:
You can use the MMM
format as in:
DateTime.Now.ToString("yyyy-MM-dd => MMM yyyy")
哪个会产生:
2014-08-06 => Aug 2014
这篇关于格式化日期字符串缩写月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文