Set the default regional date format in vb.net
Posted on 2004-09-05
I've just started porting an old ASP application to VB.NET and I'm having problems with the good old regional date format issue I've encountered in ASP before.
Even thougth the regional date format on the server is set to UK format (i.e. "dd/mm/yyyy"), all dates are being reported back as US format ("mm/dd/yyyy"). This is a problem because the VB.NET code is passing arrays of dates back to the ASP and it is going to cause big difficulties if I can't set some sort of default format up.
I have tried playing about with the Format command, but that doesn't always seem to work... I also found the following function on a Microsoft website:
Function FormatDate(ByVal culture As String, ByVal thedate As String, Optional ByVal outputformat As String = "OtherDateTime") As String
If IsDate(thedate) Then
Dim thisDate As Date = CDate(thedate)
Dim ci As System.Globalization.CultureInfo = New System.Globalization.CultureInfo(culture, False)
Dim dt As System.Globalization.DateTimeFormatInfo = ci.DateTimeFormat
Select Case outputformat
I am passing "en-gb" in as the regional code, but returned values are unpredictable.
How do I force the UK date format to be used for everything?