Copied to clipboard

Flag this post as spam?

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

  • Connie DeCinko 95 posts 247 karma points
    May 20, 2019 @ 18:55
    Connie DeCinko

    Format date of Nested Content list item

    How can I change the date format for an item in a Nested Content list in the back office? By default it shows year first. I want dd/mm/yyyy.

    enter image description here

  • Markus Johansson 1756 posts 5136 karma points c-trib
    May 20, 2019 @ 19:52
    Markus Johansson

    You should be able to use a angular filter in the label, something like this

    {{createDate | date:'yyyy-MM-dd HH:mm:ss Z'}}

    Edit: Or... maybe not. Some dates are returned as strings from the Umbraco APIs... then you would first have to convert the string to a JS-date and then format it... maybe could be done using momentjs..

    Something like this

    {{moment(createDate).format("MMM Do YY")}}

    I’m not sure that this would work... and you might have to include momentsjs introt he backoffice using a package.manifest-file

  • Connie DeCinko 95 posts 247 karma points
    May 20, 2019 @ 20:51
    Connie DeCinko

    Yeah, by itself, that does not return anything. Seems like this ability should be out of the box.

  • Markus Johansson 1756 posts 5136 karma points c-trib
    May 21, 2019 @ 06:49
    Markus Johansson


    I just had a closer look at this since I created my example from my phone without access to any computer to test with.

    First of all, Nested Content does not store the create date, it just stores a minimal amount of data for the created item

    This is from the umbraco cache-file in the app_data folder:

     "name":"Item 1 Hallo",
     "eventDate": "2019-05-26 08:31:08"
      "name":"Item 2 Test",
       "information":"Mamma mia"
      "eventDate": "2019-05-23 08:31:08"

    So it only stores some data about the documentype, a key and the generic properties, not a standard property like "create date". Any way. As you can see the eventDate (or any date) is stored as a string formatted like in your screenshot.

    I tested the example code that I was proposing and as you say it does not render anything, and it does not throw any errors.


    And since the date is just a string, the standard filter in AngularJS will not work either.

    {{eventDate | date:'yyyy-MM-dd HH:mm:ss Z'}}

    I guess that if you really need to format the date you could try to create your own AngularJS filter that’s using MomentJs to first convert the string to a date and then formats the date from there. Maybe something like this:

    You would then need to include this filter in a js-file that you reference in a package.manifest file to the the Umbraco backoffice to load your filter.

    I do see that this is a complicated solution to a simple problem but there is no built in way to format the date as far as I know.

    Hope you find your way around this!

  • Kristian Ravnevand 93 posts 213 karma points
    May 26, 2020 @ 08:32
    Kristian Ravnevand

    I think Erik-Jan's answear at this page solves this problem in Umbraco 8

    {{dateUntill| momentDateTimeZone:"YYYY-MM-DD"}}

Please Sign in or register to post replies

Write your reply to: