📜  在 c# 代码示例中将月份数转换为文本

📅  最后修改于: 2022-03-11 14:48:44.045000             🧑  作者: Mango

代码示例1
//For short month names 
string monthName = new DateTime(2010, 8, 1)
    .ToString("MMM", CultureInfo.InvariantCulture);

//For long/full month names for spanish("es") culture
string fullMonthName = new DateTime(2015, i, 1).ToString("MMMM", CultureInfo.CreateSpecificCulture("es"));

//or
string monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(8);