DateTime Convert from int to Month Name in C#, Silverlight

孤街浪徒 提交于 2019-11-30 10:59:10

Try DateTime.Now.ToString("MMMM")

See MSDN: Custom Date and Time Format Strings for other format strings.

You can also get it like this:

var month = 7;
var dtf = CultureInfo.CurrentCulture.DateTimeFormat;
string monthName = dtf.GetMonthName(month);
string abbreviatedMonthName = dtf.GetAbbreviatedMonthName(month);

Resources:

If you want the full date (in your case: February 2, 2002) use: myDate.ToString("MMMM dd, yyyy")

For just the month: .ToString("MMMM") is correct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!