Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, August 20, 2015

Different ways to get item Created date time on web page in Sitecore



Sometime we need to show item created date and time in Sitecore. Here are some of the possible ways to show on aspx or ascx control.

I am using repeater here but you can directly use on page

<asp:Repeater ID="rpCars" ItemType="Sitecore.Data.Items.Item" runat="server">
    <ItemTemplate>
        <p>
            <strong>

               Way 1 : <%# Item.Fields[Sitecore.FieldIDs.Created].Value %> <br />
               Way 2 : <%# Item.Fields["__Created"].Value %> <br />
               Way 3 : <sc:FieldRenderer ID="FieldRenderer1" FieldName="__Created" runat="server" DataSource="<%#: Item.ID %>" /> <br />
               Way 4 : <%# Sitecore.DateUtil.FormatIsoDate(Item.Fields[Sitecore.FieldIDs.Created].Value, "dd-MMM-yyyy hh:mm") %>
            </strong>
        </p>
    </ItemTemplate>
</asp:Repeater>

Please leave your comments or share this code if it’s useful for you. Also share if you know any other way to get it.

1 comment: