从月份编号获取月份名称 [英] Get Month name from month number

查看:32
本文介绍了从月份编号获取月份名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
如何在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();

任何建议...

推荐答案

对于短月份名称使用:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆