G
Guest
Example:
On a web page the user enters for a date: 12/05/2006
They're in the UK, so this is 12th May 2006
Once this value arrives in a datetime variable in VB, date.month = 12 and
not 5 as should be expected, ie, it has assumed a US date formatting.
We have tried the following:
Setting both
System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentUICulture
to "EN-GB"
And
Dim ukCulture As CultureInfo = New CultureInfo("en-GB")
Dim myDateTime As DateTime = DateTime.Parse(myDate, ukCulture.DateTimeFormat)
Neither of these approaches have resolved the fundamental issue (US format
in the resulting variable rather than a UK date (month - day swapped).
Also, .ToString versions of the variables have been passed around, using a
string to capture the variable before processing and so on.
Also, once you change the input date to something like 28/1/2006, the
processes fail to even accept it as a valid date format (obviously because 28
is greater than the maximum month of 12)
Control Panel on the development machine shows Uk/British settings in all
appropriate places.
Is there a way (and there surely must be?) to set ASP/VB.Net to use local
settings by default when processing this data? Or a genuine way of
converting between types that is actually reliable and doesn't require us to
make an assumption that the date is in x format so we can string strip and
rearrange.
Using Visual Studio 2005 Professional on XP Pro SP2, all known updates and
patches installed, with the environment being on this single machine.
Thanks
On a web page the user enters for a date: 12/05/2006
They're in the UK, so this is 12th May 2006
Once this value arrives in a datetime variable in VB, date.month = 12 and
not 5 as should be expected, ie, it has assumed a US date formatting.
We have tried the following:
Setting both
System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentUICulture
to "EN-GB"
And
Dim ukCulture As CultureInfo = New CultureInfo("en-GB")
Dim myDateTime As DateTime = DateTime.Parse(myDate, ukCulture.DateTimeFormat)
Neither of these approaches have resolved the fundamental issue (US format
in the resulting variable rather than a UK date (month - day swapped).
Also, .ToString versions of the variables have been passed around, using a
string to capture the variable before processing and so on.
Also, once you change the input date to something like 28/1/2006, the
processes fail to even accept it as a valid date format (obviously because 28
is greater than the maximum month of 12)
Control Panel on the development machine shows Uk/British settings in all
appropriate places.
Is there a way (and there surely must be?) to set ASP/VB.Net to use local
settings by default when processing this data? Or a genuine way of
converting between types that is actually reliable and doesn't require us to
make an assumption that the date is in x format so we can string strip and
rearrange.
Using Visual Studio 2005 Professional on XP Pro SP2, all known updates and
patches installed, with the environment being on this single machine.
Thanks