Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Phil Johnson - 09 Feb 2008 14:16 GMT
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?
Signature

Regards,

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

Alexey Smirnov - 10 Feb 2008 10:11 GMT
On Feb 9, 3:16 pm, Phil Johnson
<PhilJohn...@discussions.microsoft.com> wrote:
> I am setting the current culture on the current thread in my global.asax.cs
> application_start() event as follows:
[quoted text clipped - 19 lines]
> 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"...
Phil Johnson - 10 Feb 2008 11:25 GMT
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 :-)

Signature

Regards,

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

> On Feb 9, 3:16 pm, Phil Johnson
> <PhilJohn...@discussions.microsoft.com> wrote:
[quoted text clipped - 29 lines]
>
> <globalization culture="en-GB" uiCulture="en-GB"...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.