Copied to clipboard

Flag this post as spam?

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


  • rajesh 4 posts 74 karma points
    Aug 24, 2020 @ 08:34
    rajesh
    0

    Umbraco 8 DateTime Picker

    Umbraco 8 DateTime picker.

    I am trying to render the only date. but it is showing the time as well.

    Anybody, could you please tell me how to do DateTime formatting with format specifier. so that I can render DateTime as per my requirement.

  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 24, 2020 @ 16:13
    Steve Morgan
    0

    It's C# so just format the date or use the tostring format.

    https://www.c-sharpcorner.com/blogs/date-and-time-format-in-c-sharp-programming1

    in Razor you might need to use some brackets e.g.

    @(Model.MyDateField.ToString("dddd, dd MMMM yyyy"))
    
  • rajesh 4 posts 74 karma points
    Aug 24, 2020 @ 16:21
    rajesh
    0

    In my case i am not using models builder

    foreach(var post in posts)
    {
      @post.Value("postedDate")
    }
    
  • Dhanesh Kumar MJ 167 posts 543 karma points MVP c-trib
    Aug 24, 2020 @ 17:50
    Dhanesh Kumar MJ
    0

    Hi rajesh,

    No need to use model builder, it's a c# related stuff,that is steve writes here ;)

    foreach(var post in posts) {

    @post.Value("postedDate").ToString("dddd, dd MMMM yyyy"));

    }

    Regards Dhanesh;)

  • rajesh 4 posts 74 karma points
    Aug 25, 2020 @ 04:55
    rajesh
    0

    enter image description here

  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 25, 2020 @ 13:19
    Steve Morgan
    0

    Hi,

    As I said in my post:

    in Razor you might need to use some brackets e.g.

    @(post.Value("postDate").ToString("dddd, dd MMMM yyyy"))
    
  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 25, 2020 @ 13:21
    Steve Morgan
    0

    Razor can be started with just an '@' but if you have complicated snippets with multiple lots of brackets and dots it gets confused. So start with @(xxxx ) and then everything in the brackets is treated as c#.

    HTH.

    Steve

  • 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