Try Now
More in this section

Forums / Developing with Sitefinity / Date formatting not applying correct

Date formatting not applying correct

3 posts, 0 answered
  1. Andrew Booth
    Andrew Booth avatar
    21 posts
    20 Jul 2009
    07 Apr 2011
    Link to this post
    I am using this:

    <telerik:DateTimeLiteral runat="server" ID="Event_Start" DateFormatString="d">

    and the format it is applying is "4/14/2011". It should ONLY display the day. Why is "d" showing the full date?

    Also when I change "d" to "dd" or "ddd", it errors out and says Input string not in correct format...

    Any ideas?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    07 Apr 2011
    Link to this post
    Hello Andrew,

    The control works with the standard DateTime format


    You can customize the ListPageMaster template and set a label with a custom format


    <script type="text/C#" runat="server">
         public void Page_Load(object sender, EventArgs e)
             this.repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
         void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
             if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                 var cntrl = (Literal)e.Item.FindControl("Event_End");
                 if (cntrl != null)
                     var content = (Telerik.Cms.Engine.IContent)e.Item.DataItem;
                     if (content != null)
                      var date = (DateTime)content.GetMetaData("Event_Start");
                      var ds = date.ToString("M.d.yyyy h:mm tt");
                      cntrl.Text = ds;

    Best wishes,
    Ivan Dimitrov
    the Telerik team

  3. Scott
    Scott avatar
    4 posts
    27 May 2010
    07 Apr 2011
    Link to this post
    Ivan - 

    That makes sense now. I was under the impression it worked with custom formats as well outside of the standard ones.

    I'll create a custom format with some coding then.

Register for webinar
3 posts, 0 answered