tags:

views:

44

answers:

4

I want to display my date like so in VB.NET

2008/01/22 14:23:15

How is this done in code?

This does not give me enough: lblDate.Text = Today.Date

+2  A: 

Try

lblDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
Binary Worrier
and if i want to place the year first like in my example?
Etienne
Apologies, should be `DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")`
Binary Worrier
+6  A: 

This should display the way you want:

Dim formattedDate As String = Date.Today.ToString("yyyy/MM/dd HH:mm:ss")

And see Custom DateTime Format Strings for a complete reference.

Dan Tao
A: 

Please try : Date.Now

Amit
A: 

This blog post has a good description of how to do string formatting: http://idunno.org/archive/2004/07/14/122.aspx

ilivewithian