在 VB.NET 中获取当前时间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36188741/
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-17 19:46:32  来源:igfitidea点击:

Getting the current hour's in VB.NET

vb.net

提问by Danny

I'm writing a program in VB.NET that needs to get the current time.
Does anybody know of a method that will do that?

我正在 VB.NET 中编写一个需要获取当前时间的程序。
有人知道可以做到这一点的方法吗?

回答by Danny

When I tried Plutonix's code Dim thisHour = DateTime.Now.TimeofDay.Hours
I found this code while typing TimeOfDay
TimeOfDay.Hourfor Hour. TimeOfDay.Minutefor Minute. TimeOfDay.Secondfor Second
And I'm very happy, thank you Plutonix

当我尝试 Plutonix 的代码时,Dim thisHour = DateTime.Now.TimeofDay.Hours
我在输入TimeOfDay
TimeOfDay.HourHour 时发现了这段代码。TimeOfDay.Minute分钟。TimeOfDay.Second对于第二
我很高兴,谢谢 Plutonix

回答by Hirbod Behnam

Simple:

简单的:

DateTime.Now.TimeofDay.Hours