I have Textbox1 on my form in which i want to display current Date and/or Time in a custom format.
Textbox1.Text = Now is returning me the date and time in a prefixed format
How do i do this if i want the textbox1 to show this: 31/12/07, 22:50 ?
Printable View
I have Textbox1 on my form in which i want to display current Date and/or Time in a custom format.
Textbox1.Text = Now is returning me the date and time in a prefixed format
How do i do this if i want the textbox1 to show this: 31/12/07, 22:50 ?
rough guess as I have only looked into vb.net :
Code:dim dte as date = now
txtDate.text = dte.day & " " & dte.month & " " 'etc... properties available on intellisense
The toString method allows you to specify a format
Date.Now.ToString("dd/MM/yy HH:mm")
so,
Code:Textbox1.Text = Date.Now.ToString("dd/MM/yy HH:mm")
Just do this:
vb Code:
Me.TextBox1.Text = Date.Now.ToString("dd/MM/yyyy, HH:mm")
Thank you, that did the trick !
What if i want to set the same kind of value in DateTimePicker control ???
SEt the Format Property to Custom and the CustomFormat Property to dd/MM/yy HH:mm
Please don't post the same question more than once.
http://www.vbforums.com/showthread.php?t=469995