How to

get localized month name from integer

Published: 9. October 2011 | Updated: 12. October 2011
License: Microsoft Public License (MS-PL)
Categories: Globalization » Calendar
Tags: C# DateTime Globalization
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Globalization;

Code

var culture = CultureInfo.GetCultureInfo("en-US");
var dateTimeInfo = DateTimeFormatInfo.GetInstance(culture);

int monthNumber = DateTime.Today.Month;
string monthName = dateTimeInfo.GetMonthName(monthNumber);

Console.WriteLine(monthName);
Console Output:
October
Send us feedback about this snippet »



Related Snippets: