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

Forums / Developing with Sitefinity / news with specific Date language

news with specific Date language

4 posts, 0 answered
  1. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    13 Oct 2010
    Link to this post
    Hello  Telerik Team
    I have a Customize NewsView  where the DateFormat property define the format of the Date.
    There is a property to set the language or the culture of the Date "Publication Date" always in a specific language in this case "Italian"?
    I want that the language date will not depend of the Language of the server.
    On my server it's in Italian but on another one it can change and i want to show the date always in Italian.

    Thank you Very much.

     
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Oct 2010
    Link to this post
    Hello Bachar,

    Please take a look at this article that explains how you can control the date time format.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    13 Oct 2010
    Link to this post
    Thank you for your suggestion
     the DateFormat don't define the culture but the format
    i tried something like this but with no result
    MyBase.SetItemMetadata(itemContainer, contentItem)
    Dim lt As Literal = CType(Me.FindContentViewControl("Publication_Date", itemContainer), Literal)
    Dim dt As Date = CType(lt.Text, DateTime)
    lt.Text = dt.ToString("dd,MMMM,yyyy", New System.Globalization.CultureInfo("it-IT"))


    all I need to do is to have the month in italian on any server where my application can be run!

    thank you
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Oct 2010
    Link to this post
    Hi Bachar,

    How a given date is shown depends on the culture you use and this is not something specific to Sitefinity.
    You also use a specific culture where the correct class is CreateSpecificCulture. The article also shows that you can create IFormatProvider to set a specific format for the date you wan to return. Generally you have to work with valid date time formats ( shown in the article) otherwise Parse method could fail.

    DateTime date1 = new DateTime(2008, 4, 10);
    Console.WriteLine(date1.ToString("D",
                      CultureInfo.CreateSpecificCulture("en-US")));
    // Displays Thursday, April 10, 2008                       
    Console.WriteLine(date1.ToString("D",
                      CultureInfo.CreateSpecificCulture("pt-BR")));
    // Displays quinta-feira, 10 de abril de 2008                       
    Console.WriteLine(date1.ToString("D",
                      CultureInfo.CreateSpecificCulture("es-MX")));
    // Displays jueves, 10 de abril de 2008


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
4 posts, 0 answered