Get the current date and time

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 
1

4 Answers

use DateTime.Now

try this:

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

Try this one:

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

DateTimePicker1.value = Format(Date.Now)

Get Current DateTime

Now.ToShortDateString() DateTime.Now Today.Now 

You Might Also Like