Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesper Skjønnemand 66 posts 441 karma points c-trib
    Dec 07, 2018 @ 10:00
    Jesper Skjønnemand
    0

    @Umbraco.Field(item, "eventDate")

    My list of events contain this

    <p class="item_date">@Umbraco.Field(item, "eventDate")</p>
    

    Which results in this

    <p class="item_date">3/9/2019 12:00:00 AM</p>
    

    I would prefer this

    <p class="item_date">9 MAR 2019</p>
    

    Suppose I need to add this

    .ToString("dd MMM yyyy")
    

    But I can't seem to figure out where.

    Suggestions? Other solutions?

    Best

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Dec 07, 2018 @ 14:48
    Alex Skrypnyk
    0

    Hi Jesper

    Try this code:

    <p class="item_date">@(Umbraco.AssignedContentItem.GetPropertyValue<DateTime>("eventDate").ToString("dd MMM yyyy"))</p>
    

    Thanks

    Alex

  • Kuan Tan 2 posts 92 karma points
    Dec 07, 2018 @ 14:49
    Kuan Tan
    100

    Hi,

    You can probably do the following

    @Convert.ToDateTime(Umbraco.Field(item, "eventDate").ToString()).ToString("dd MMM yyyy")

    or

    @CurrentPage.eventDate.ToString("dd MMM yyyy")

    Regards, Tan

Please Sign in or register to post replies

Write your reply to:

Draft