Copied to clipboard

Flag this post as spam?

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


  • Henrik Bro 6 posts 55 karma points
    Jul 21, 2020 @ 09:38
    Henrik Bro
    0

    Nested Content with datepicker - can not format date in view

    Hi,

    I have tried to create a partial view (Nested Content) like this:

    var items = Model.Value<IEnumerable<IPublishedElement>>("Test");
    
    foreach(var item in items)
    {
        <p>@item.Value("head")</p>
        <p>Sidst redigeret: @item.Value("date")</p>
        <p>@item.Value("body")</p>
    }
    

    But I can not figure out how to format the "date" to d. MMMM YYYY

    Found this in the forum:

    @(Model.Value<DateTime>("datePicker").ToString("dd MM yyyy"))

    But @item.Value<DateTime>("date").ToString("d. MMMM YYYY")) - returns this error: Argument 1: cannot convert from 'method group' to 'HelperResult''

    Any idea how to solve this?

  • Henrik Bro 6 posts 55 karma points
    Jul 25, 2020 @ 16:24
Please Sign in or register to post replies

Write your reply to:

Draft