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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGhpbCBKb2huc29u?=

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

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

    System.Threadin g.Thread.Curren tThread.Current Culture = new
    System.Globaliz ation.CultureIn fo("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.To UniversalTime() .ToLongDateStri ng();

    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

  • Alexey Smirnov

    #2
    Re: CurentCulture set to en-GB but dates are appearing in US formatst

    On Feb 9, 3:16 pm, Phil Johnson
    <PhilJohn...@di scussions.micro soft.comwrote:
    I am setting the current culture on the current thread in my global.asax.cs
    application_sta rt() event as follows:
    >
    System.Threadin g.Thread.Curren tThread.Current Culture = new
    System.Globaliz ation.CultureIn fo("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.To UniversalTime() .ToLongDateStri ng();
    >
    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 formattingso
    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. pjsoftwaredevel opment.com
    Hi Phillip,

    either set the culture in Application_Beg inRequest (instead the
    Application_Sta rt)
    or use Globalization section in the web.config.

    <globalizatio n culture="en-GB" uiCulture="en-GB"...

    Comment

    • =?Utf-8?B?UGhpbCBKb2huc29u?=

      #3
      Re: CurentCulture set to en-GB but dates are appearing in US forma

      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



      "Alexey Smirnov" wrote:
      On Feb 9, 3:16 pm, Phil Johnson
      <PhilJohn...@di scussions.micro soft.comwrote:
      I am setting the current culture on the current thread in my global.asax.cs
      application_sta rt() event as follows:

      System.Threadin g.Thread.Curren tThread.Current Culture = new
      System.Globaliz ation.CultureIn fo("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.To UniversalTime() .ToLongDateStri ng();

      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. pjsoftwaredevel opment.com
      >
      Hi Phillip,
      >
      either set the culture in Application_Beg inRequest (instead the
      Application_Sta rt)
      or use Globalization section in the web.config.
      >
      <globalizatio n culture="en-GB" uiCulture="en-GB"...
      >

      Comment

      Working...