Copied to clipboard

Flag this post as spam?

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


  • Cedeste 36 posts 128 karma points
    Feb 07, 2023 @ 15:00
    Cedeste
    0

    How to stop the Date Picker from showing time

    I followed the instructions found in this video on the Umbraco Learning Base youtube channel: https://www.youtube.com/watch?v=xMS-rtqhWzU&t=220s

    I have my blog working, but the date picker is showing the time, I need it to NOT show the time.

    I've selected the "Date Picker," not the "Date Picker with Time" but the time is displaying.

    Ex: 2/1/2023 12:00:00 AM

    This is my code:

       @{
                    var selection = Umbraco.Content(Guid.Parse("8f22dca9-3862-48d7-b22b-b5f064dc4419"))
                    .ChildrenOfType("newsItem")
                    .Where(x => x.IsVisible())
                    .OrderByDescending(x => x.CreateDate).Take(2);
    
    
    
                }
    
    
                    @foreach (var item in selection)
                    {
                        var thumbnail =item.Value<IPublishedContent>("thumbnailImage");
                         <div class="col-md-4">
                        <div class="LNcard-body">
                            <div class="thumbnail-latest-blog">
                                <a href="@item.Url()" class="featured-link"><div class="thumbnail-latest-img" style="background-image:url('@thumbnail.Url()')"></div></a>
                                     <h5 class="card-title" style="font-weight: bold;">@item.Value("title")</h5>
                                    <p class="LNpubmeta"><i>@item.Value("publishedOn")</i></p>
                                    <p class="card-text">@item.Value("preview")</p>
                                    <a href="@item.Url()" class="btn btn-pelican-secondary" role="button" title="Read More" alt="Read More">Read More</a>
                            </div>
                    </div>
                    </div>
                    }
    

    The publishedOn value is the date picker. Date is configured to show as DD-MM-YYYY

    Any suggestions for how to remove the time would be great! Thank you.

  • Huw Reddick 1736 posts 6076 karma points MVP c-trib
    Feb 07, 2023 @ 15:45
    Huw Reddick
    100

    You will need to use a date format string e.g.

    var publishedDate = item.Value<DateTime>("publishedOn").ToString("dd-MM-yyyy")
    
  • Cedeste 36 posts 128 karma points
    Feb 07, 2023 @ 16:53
    Cedeste
    0

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft