CurentCulture set to en-GB but dates are appearing in US format st

P

Phil Johnson

I am setting the current culture on the current thread in my global.asax.cs
application_start() event as follows:

System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-GB");

In my default.aspx.cs I then set the text of a label from a datetime
variable like this:

lblDate.Text = DateTime.Now.ToUniversalTime().ToLongDateString();

But the date is formatted in United States format.

I am hosting on a US host, so I would expect the format to be US without
setting the CurrentCulture, but I am clearly setting that to UK formatting so
I thought the date should be formatted as such.

Do I need to do something differently?
--
Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com
 
G

Guest

I am setting the current culture on the current thread in my global.asax.cs
application_start() event as follows:

System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("en-GB");

In my default.aspx.cs I then set the text of a label from a datetime
variable like this:

lblDate.Text = DateTime.Now.ToUniversalTime().ToLongDateString();

But the date is formatted in United States format.

I am hosting on a US host, so I would expect the format to be US without
setting the CurrentCulture, but I am clearly setting that to UK formatting so
I thought the date should be formatted as such.

Do I need to do something differently?
--
Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Developmentwww.pjsoftwaredevelopment.com

Hi Phillip,

either set the culture in Application_BeginRequest (instead the
Application_Start)
or use Globalization section in the web.config.

<globalization culture="en-GB" uiCulture="en-GB"...
 
P

Phil Johnson

Thanks for that,

I'm guessing that's because sessions run in a different thread to the
application?

As long as it works though, I'm happy :)

--
Regards,

Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top