vb.net 无法从当前日期获取月份

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14426813/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 16:35:43  来源:igfitidea点击:

Not able to get month from current date

vb.netdate

提问by ken

Am trying to extract month from the current date but in vain. I am using the code:

我试图从当前日期中提取月份但徒劳无功。我正在使用代码:

    Format(Today.Date, "mmmm")

However when I try to run it to display month like January it instead displays 00. I thought that this would work but it isn't. What can I do to get the month from current date in vb.net using a simple approach like a single function?

但是,当我尝试运行它以显示像一月这样的月份时,它会显示 00。我认为这会起作用,但事实并非如此。我该怎么做才能使用像单个函数这样的简单方法从 vb.net 中的当前日期获取月份?

回答by Abdusalam Ben Haj

Try This :

尝试这个 :

DateTime.Today.ToString("MMMM")

Check out Thisfor detailed date formatting options.

查看以获取详细的日期格式选项。

回答by Arpit

try this

尝试这个

    MonthName(Now.Date.Month(),true)

回答by spajce