Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date problem US format, I want UK?

Status
Not open for further replies.

IndyGill

Technical User
Jan 15, 2001
191
0
0
GB
Hi

I am having a little problem (OK maybe not so little as it has had me puzzled) with the date format. When I pass a date via my .Net page it seems to interpret it in US format when I want it to interpret in UK format. For example I have built a very basic page with a textbox, button and a label. The label is filled with date I input into textbox when I click the button, a sample of my code is below.

lblDate.Text = (FormatDateTime(txtDate.Text, DateFormat.LongDate))

So if I enter 07/09/03 the label returns 09 July 2003 when I want it to return the 7th September 2003. So if I enter 13/09/03 it will throw and error as it thinks there is no 13th months.

I have checked my Regional Settings and they are all in UK format. Im just wondering if there is another setting I am over looking on my PC or is there a Dot Net Framework configuration I need to do.

Many thanks in advance
 
you can do it in 2 ways:

lblDate.Text = (FormatDateTime("{0:dd/MM/yyyy}", txtDate.Text)

OR use system threading like this:

Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture("en-UK")
System.Threading.Thread.CurrentThread.CurrentCulture = culture

You should read more on this before using it. I'm not sure if you can use "en-UK", so far it works for me with "en-US" and "fr-Fr"
 
Hi jn03

Thanks for the above, so am I write in saying that its not a problem with my PC setup and that every fresh installation if the .Net Framework automatically defaults to a US date format.

Can I put the culture setting in my web.config as I would like this setting to apply site wide.

Many thanks for all your help
 
I think its a machine problem as I have just tested it on my Windows 2000 machine and it seems fine. So it seems to be a problem with my XP Pro machine setup.

Sorry for using this forum to solve this problem. However if anybody has come accross this problem please feel free to let me know you get round it it.

I checked the below settings and they are all set to British English

1) Regional Setting
2) IE6 language settings

I cant think of anything else to check, its driving me mad!!!!
 
I found this article, I think it helps you:

according to this article, you can change your pc language setting through the control panel. (you'll need more research on how to do this).
As for culture setting, the setting should be "en-GB", not "en-UK" like I've guessed :) and you can set it through the global.asax file. My guess is you can also set it through the webconfig file too, but I don't know how. Sorry, that's all I can help. I'm just a newbie :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top