![]() |
|
|
#1 (permalink) |
|
Registered User
Join Date: Oct 2004
Posts: 31
|
The Date Devil
personally i hate dates.......more pages have been dedicated to the utter confusion caused by dates and regional settings than to the Iraq war
and its still confusin ok my problem...british site.......take the date in in british format fine on my machine up here i get this [InvalidCastException: Cast from string "28/02/1972" to type 'Date' is not valid.] Microsoft.VisualBasic.CompilerServices.DateType.Fr omString(String Value, CultureInfo culture) +162 Microsoft.VisualBasic.CompilerServices.DateType.Fr omString(String Value) +53 WDate.UserRegister.btnRegister_Click(Object sender, ImageClickEventArgs e) +396 ok so i believe that the vb.net function cdate takes its setting from the server its running from, but then i am sure paul and his team will have set the server up as british anyone any advice? |
|
|
|
|
|
#2 (permalink) |
|
Registered User
Join Date: Oct 2004
Posts: 31
|
ok tried a few thangs
put a label into the page to show me LCID my machine Default LCID is: 2057 Date format is: 27/12/2004 00:01:41 cat server Default LCID is: 1033 Date format is: 12/27/2004 12:01:12 AM gonna try messing with the web-config.........can't remember where i got the one thats with the site up here........just know its different from my own machine <globalization requestEncoding="windows-1252" responseEncoding="windows-1252" fileEncoding="windows-1252" culture="en-US" uiCulture="en-US" /> going to try changing to en-GB |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Feb 2004
Posts: 17
|
Also, another way of making really sure is to put code in the Application_BeginRequest method within the global.asax application overriding the default UI Culture with a new CultureInfo object.
For example, in my application (which is multilingual) i do the following. Code:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
try
{
CultureInfo cultureInfo;
if(SessionManager.ItemExists("UICulture"))
{
cultureInfo = new CultureInfo(SessionManager.GetItem("UICulture").ToString());
}
else
{
cultureInfo = new CultureInfo(HttpContext.Current.Request.UserLanguages[0]);
}
Thread.CurrentThread.CurrentUICulture = cultureInfo;
}
catch //not too fussed about catching any specific exception
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(ConfigManager.GetItem("Locale.DefaultCulture"));
}
}
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Jul 2003
Location: West Midlands
Posts: 188
|
You chaps seem to be putting in an awful lot of work to make dates meet individual requirements.
If only people would conform to ISO 8601 there would be no problem. YEAR-MONTH-DAY-HOUR-MINUTE-SECOND ISO 8601 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|