locked
Problem with asp.net Datetime RRS feed

  • Question

  • User2108435954 posted

    Hi All

    I have a fantastic problem with asp.net datetime...!!!

    My computer OS has windows server 2003 sp2. All Languages and Time configration in regional and language options set to united  states but when I call asp.net datetime in my web page I get this string ( 2011/1/20 12:11:22 ب.ظ ).

    ب.ظ has a farsi date and time format but I datetime format in regional options has English (United States)

    This problem verry important for me becusse when I post datetime to sqlserver database (Datatype: datetime) I getting an error insert nvarchar to datetime...!!!???

    IF any of my friend can help me, please answer to this question.

    Friday, January 21, 2011 2:08 AM

Answers

  • User-427562574 posted

    Check the current culture of the processing thread:

    System.Threading.Thread.CurrentThread.CurrentCulture

    It is usually set to the top-most language defined in the browser and passed to the server using in HTTP Header: Accept-Language.

    You can change it by assigning in Page_Load:

    Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
     
    Or as the first answer specifies, in Web.config.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 24, 2011 2:40 PM

All replies

  • User1401801381 posted

    weird issue


    in you web.config file, did you set the culture ?

    <system.web>
        <globalization culture="en-US" />


    Friday, January 21, 2011 3:54 AM
  • User712082397 posted

    Are you setting current thread's UI culture/ current culture anywhere? 

    Friday, January 21, 2011 9:46 AM
  • User-427562574 posted

    Check the current culture of the processing thread:

    System.Threading.Thread.CurrentThread.CurrentCulture

    It is usually set to the top-most language defined in the browser and passed to the server using in HTTP Header: Accept-Language.

    You can change it by assigning in Page_Load:

    Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
     
    Or as the first answer specifies, in Web.config.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 24, 2011 2:40 PM