1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Display event date in specific culture

Display event date in specific culture

4 posts, 0 answered
  1. Priya Ramesh
    Priya Ramesh avatar
    26 posts
    Registered:
    23 Jul 2009
    28 Sep 2009
    Link to this post
    Hi ,
       I am trying to display the month name in specific culture for events. I noticed that the currentthread,currentculture is always en-US. So I am not able to use dateformatinfo to get the cultured month name. Am I doing something wrong?

    Thanks,
    Priya
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    29 Sep 2009
    Link to this post
    Hi Priya Ramesh,

    Most probably you are not setting the culture. Could you give a try to the following samle shown below:

            DateTime dateTime = DateTime.Now;  
            // Sets the CurrentCulture property to U.S. English.  
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");  
            Response.Write(dateTime.ToString("d")); 

    You could try using different date patterns or custom format. 

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Priya Ramesh
    Priya Ramesh avatar
    26 posts
    Registered:
    23 Jul 2009
    29 Sep 2009
    Link to this post
    When I change the culture to "it" using the languagebar only currentuiculture changes to the culture "it".Does the currentculture stays as en-US (and not change to it-IT)?

    Thanks,
    Priya
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Sep 2009
    Link to this post
    Hi Priya Ramesh,

    Try using CurrentUICulture. The culture is changed right after the PostBack. You could observer the behavior using the code below:

    CultureInfo ci = CultureInfo.CurrentUICulture; 
    Response.Write("<h1>" + ci.ToString() + "</h1>"); 

    In the previous sample we explicitly set the current culture by calling new CultureInfo(string culture);

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered