More in this section

Forums / Developing with Sitefinity / Display Time with Blog Posts

Display Time with Blog Posts

3 posts, 0 answered
  1. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    02 Feb 2010
    Link to this post
    By Default, Blog post control displays only time, the list given in blogpost control is only date formats, there is no time included in it. when i gave the formatstring in code to display time as well. it shows 12:00:00AM with every post, although in sf_GCMetaData table the time is correct.
    Please help me solve my this issue
    Regards
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Feb 2010
    Link to this post
    Hi Muhammad Saqib,

    This is a know issue. You can show only the date without the time. Another option is creating a custom class that inherits from CommentsList, override InitializeControls and subscribe for ItemDataBound event of CommentsRepeater control. From there you can get the IComment object and create a new label that shows comment creation date using GetCreationDate();

    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    02 Feb 2010
    Link to this post
    I have solved the issue as follows...

    In ContentViewItemList.ascx

    Hide the Publication_Date control.
    <telerik:DateTimeLiteral runat="server" ID="Publication_Date" Visible="false"  ></telerik:DateTimeLiteral>


    and in Code-Behind file, do this..

    protected void Page_Load(object sender, EventArgs e)
       {
           repeater.ItemDataBound += new RepeaterItemEventHandler(repeater_ItemDataBound);
     
       }

    and then in ItemDataBound event..

    void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
     
     DateTimeLiteral Publication_Date = e.Item.FindControl("Publication_Date") as DateTimeLiteral;
                    Publication_Date.DateFormatString = "MMMM d, yyyy - HH:mm ";
                    Publication_Date.Visible = true;
    }
    }

    Looks really strange , but it worked ! :-)

    Regards
    Saqib
Register for webinar
3 posts, 0 answered