Copied to clipboard

Flag this post as spam?

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


  • Sharmarke Hujale 103 posts 346 karma points
    Oct 24, 2015 @ 22:59
    Sharmarke Hujale
    0

    It always creates the same datetime!

    I got some problem on my blog page. When I create a blog-post the date is always 15 October - and that is the date, when I created the blog page. Here is my code:

     <!--Blogs-->
                @foreach (var blogPost in items.Skip((page - 1) * pageSize).Take(pageSize).OrderBy(x => x.CreateDate))
                {
                     <!--Article-->
                    <article class="post-preview">
                        <a href="@blogPost.Url">
                            <h2 class="post-title">@blogPost.Name</h2>
                            <h3 class="post-subtitle">@blogPost.GetPropertyValue("blogSubheader")</h3>
                        </a>
                        <p class="post-meta">
                            Posted by
                            <a href="@blogPost.Url">@Model.Content.CreatorName</a>
    
                            on @Model.Content.CreateDate.ToString("MMMM d, yyyy")      
                        </p>
                    </article>
                    <hr />
                }
    

    When I create a blog-post, I want them to have the todays date, and not the same one - hope my question was understandable!

    Thanks in advance!

  • Sharmarke Hujale 103 posts 346 karma points
    Oct 25, 2015 @ 00:04
    Sharmarke Hujale
    0

    Please someone who can help me with this!

  • Nik 1413 posts 6212 karma points MVP 3x c-trib
    Oct 25, 2015 @ 00:35
    Nik
    101

    Hi Sharmarke,

    Why are you doing @Model.Content.CreateDate?

    By the looks of your code that would be the Create Date of the page as a whole not the individual blog posts.

    Because you are iterating around a collection, I suspect you need to change it to be @blogPost.CreateDate

    Try that and see how it goes.

  • Sharmarke Hujale 103 posts 346 karma points
    Oct 25, 2015 @ 12:07
    Sharmarke Hujale
    0

    I was watching a video the other day - and I'm new to Umbraco...

    But now it is working! Thanks!

  • 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