1

hello sir
how can I get my system short date format in a label in vb. net. I try this code :

Label1.Text = System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern()

but show wrong data. all time show "M/d/yyyy" format.

I change it(to "dd/MM/yyyy") manually and by coding result is same("M/d/yyyy") please help me.....

For Change the Format:

Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control Panel\International", "sShortDate", "dd/MM/yyyy")
Votes + Comments
Thanks for marking this solved
3
Contributors
3
Replies
25
Views
2 Months
Discussion Span
Last Post by xrj
1

Well to set the Text of your label, I would use the ToString method of DateTime with a format string. See here for examples.

0

Or you can change current's thread date pattern:

                Dim newCulture As System.Globalization.CultureInfo =
                    System.Threading.Thread.CurrentThread.CurrentCulture.Clone()
                newCulture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy"
                newCulture.DateTimeFormat.DateSeparator = "-"
                System.Threading.Thread.CurrentThread.CurrentCulture = newCulture
                Dim sDate As String = Now.ToString
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.