从月号获取月份名称 [英] Get Month name from month number
本文介绍了从月号获取月份名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何在c#中获取MonthName
我使用以下c#语法从月份获取月份名称,但我得到 August
我只想 Aug
。 。
I used the following c# syntax to get month name from month no but i get August
i want only Aug
..
System.Globalization.DateTimeFormatInfo mfi = new
System.Globalization.DateTimeFormatInfo();
string strMonthName = mfi.GetMonthName(8).ToString();
任何建议...
推荐答案
对于短的月份名称,使用:
For short month names use:
string monthName = new DateTime(2010, 8, 1)
.ToString("MMM", CultureInfo.InvariantCulture);
对于西班牙语(es)文化的长/满月名称
For long/full month names for Spanish ("es") culture
string fullMonthName = new DateTime(2015, i, 1).ToString("MMMM", CultureInfo.CreateSpecificCulture("es"));
这篇关于从月号获取月份名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文