Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Jun 14, 2013 @ 13:05
    René Andersen
    0

    How to use ToString("dd-MM-yyyy")

    Hello

    How do I use ToString in the code below (should be used on the "date")?

    <div class="blog-content">
    <div class="title">
    <span>@news.GetProperty("date").Value</span>
    <h2><a href="single-post.html"></a>@news.GetProperty("headline").Value</h2>
    </div>
    <p>@news.GetProperty("description").Value</p>
    </div>


    I have tried this with no luck:

    <div class="blog-content">
    <div class="title">
    <span>@news.GetProperty("date").Value</span>
    <h2><a href="single-post.html"></a>@news.GetProperty("headline").Value.ToString("dd-MM-yyyy")</h2>
    </div>
    <p>@news.GetProperty("description").Value</p>
    </div>

    Thanks in advance!

    // René

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 14, 2013 @ 13:14
    Dennis Aaen
    1

    Hi René

    Maybe this post can help you out here. It sems to be the same issue.

    http://our.umbraco.org/forum/developers/razor/19260-how-do-I-format-datetime-in-razor

    /Dennis

  • Bjarne Fyrstenborg 1286 posts 4060 karma points MVP 8x c-trib
    Jun 14, 2013 @ 13:25
    Bjarne Fyrstenborg
    0

    Hi René

    Isn't it the wrong property you are trying to format? I guess the property "headline" isn't a datetime..?

    Try with the date property:

    <div class="blog-content">
        <div class="title">
            <span>@news.GetProperty("date").Value.ToString("dd-MM-yyyy")</span>
            <h2><a href="single-post.html"></a>@news.GetProperty("headline").Value</h2>
        </div>
        <p>@news.GetProperty("description").Value</p>
    </div>

    /Bjarne

     

  • René Andersen 238 posts 684 karma points
    Jun 14, 2013 @ 13:27
    René Andersen
    0

    Hi Dennis

    Thanks!

    I solved the problem with some minor changes in the code see below:

    <divclass="blog-content">
       
    <divclass="title">
           
    <span>@news.date.ToString("dd-MM-yyyy")</span>
           
    <h2><ahref="single-post.html"></a>@news.headline</h2>
       
    </div>
       
    <p>@news.description</p>
    </div>

    // René

  • René Andersen 238 posts 684 karma points
    Jun 14, 2013 @ 13:35
    René Andersen
    0

    Hi Bjarne

    Sorry I made some changes from my original code before i posted it here and by i mistake I put in the ToString command the wrong place.

    // René

  • Bjarne Fyrstenborg 1286 posts 4060 karma points MVP 8x c-trib
    Jun 14, 2013 @ 14:11
    Bjarne Fyrstenborg
    100

    Hi René

    I'm glad you solved it.. please mark the right answer as solution :)

    Perhaps this is just a typing mistake, but I think you want to wrap anchor tag around the news headline?

    Then it should be:

    <div class="blog-content">
        <div class="title">
            <span>@news.date.ToString("dd-MM-yyyy")</span>
            <h2><a href="single-post.html">@news.headline</a></h2>
        </div>
        <p>@news.description</p>
    </div>

    /Bjarne

  • René Andersen 238 posts 684 karma points
    Jun 14, 2013 @ 14:28
    René Andersen
    0

    Hi Bjarne

    Yep that was a typing mistake but thanks anyway. :-)

    // René

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies