vb.net 获取当前日期和时间

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

Get the current date and time

vb.netwinforms

提问by Nh123

I want to get the current date and time.

我想获取当前的日期和时间。

For example:

例如:

2012/11/13 06:30:38

What I have tried:

我尝试过的:

Dim d As System.DateTime
MsgBox(d.Year) 'Return 1

回答by famf

use DateTime.Now

DateTime.Now

try this:

尝试这个:

DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")

回答by pao

Try this one:

试试这个:

System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")

回答by user3007371

DateTimePicker1.value = Format(Date.Now)

DateTimePicker1.value = Format(Date.Now)

回答by sk2185

Get Current DateTime

获取当前日期时间

Now.ToShortDateString()
DateTime.Now
Today.Now