开发者

Convert DateTime.Now.Month; as string value

开发者 https://www.devze.com 2022-12-29 04:48 出处:网络
int month=DateTime.Now.Month; It gives output as = 04 But how do I get the 开发者_如何学JAVAmonth as string \'April\' from code behind?
int month=DateTime.Now.Month;

It gives output as = 04

But how do I get the 开发者_如何学JAVAmonth as string 'April' from code behind?


string month = DateTime.Now.ToString("MMMM");

For additional hints how to use ToString to get another results, this may help: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm


string month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month);

..if you want it in the right culture


@pranay, @gsharp: The DateTime.ToString(string format) method respects the current culture.

0

精彩评论

暂无评论...
验证码 换一张
取 消