2012-11-13 11 views
19

Desidero ottenere la data e l'ora correnti.Ottenere la data e l'ora correnti

Ad esempio:

2012/11/13 06:30:38 

Quello che ho cercato:

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

Possibile duplicato [Ottenere la data corrente in Visual Basic 2008] (http://stackoverflow.com/questions/9177199/ getting-the-current-date-in-visual-basic-2008) –

risposta

43

uso DateTime.Now

provare questo:

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

grazie, lavora. – Nh123

+0

È inoltre possibile utilizzare "d" per la stringa di formato per utilizzare il formato data/ora di sistema. – xpda

2

DateTimePicker1.value = Format(Date.Now)

2

Get DateTime corrente

Now.ToShortDateString() 
    DateTime.Now 
    Today.Now 
7

Prova questo:

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