Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the current date in visual Basic 2008

Tags:

vb.net

I dont know how to get the current date in visual basic 2008. Here is a sample code

regDate = Format(Date.Now(), "ddMMMyyyy")

The output is like 7/02/1900

Need help

like image 602
Tamseyc Avatar asked Feb 07 '12 13:02

Tamseyc


2 Answers

User can use this

Dim todaysdate As String = String.Format("{0:dd/MM/yyyy}", DateTime.Now)

this will format the date as required whereas user can change the string type dd/MM/yyyy or MM/dd/yyyy or yyyy/MM/dd or even can have this format to get the time from date

yyyy/MM/dd HH:mm:ss 
like image 59
Anirudh Avatar answered Sep 30 '22 06:09

Anirudh


Try this:

Dim regDate as Date = Date.Now()
Dim strDate as String = regDate.ToString("ddMMMyyyy")

strDate will look like so: 07Feb2012

like image 42
Boeckm Avatar answered Sep 30 '22 07:09

Boeckm