Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 446 posts 1563 karma points
    May 18, 2022 @ 10:04
    Adriano Fabri
    0

    How to format dates in blocklist labels

    Hi to all, In Umbraco v8 I created a blocklist for events.

    I would to show (as label) the title and date of a single event.

    Title is ok, but the date not.

    I set the "Label" field as follow:

    Event: {{ eventTitle }} - {{ eventDate | date : "dd/MM/yyyy" }}
    

    The result, in content node, is:

    Event: 75° Festival di Cannes - 2022-05-21 00:00:00
    

    But I expected it to be:

    Event: 75° Festival di Cannes - 21/05/2022
    

    Can anyone help me to correctly format the label?

    Thank you

    Adriano

  • Dave Woestenborghs 3431 posts 11702 karma points MVP 7x admin c-trib
    May 18, 2022 @ 10:33
    Dave Woestenborghs
    0

    Hi Adriano,

    That should be correct according to the angularJs docs : https://docs.angularjs.org/api/ng/filter/date

    What do you get if you remove the date filter ? Maybe the date property is not a date but a formatted string already.

    Dave

  • Adriano Fabri 446 posts 1563 karma points
    May 18, 2022 @ 15:15
    Adriano Fabri
    0

    The date is an Umbraco DatePicker.

    Yeah, I saw the the angularJs docs before set the filter: https://docs.angularjs.org/api/ng/filter/date

    If I remove the date filter, I have the same result:

    Event: 75° Festival di Cannes - 2022-05-21 00:00:00
    

    So...the filter don't function properly, but I don't know why.

    Adriano

  • Dave Woestenborghs 3431 posts 11702 karma points MVP 7x admin c-trib
    May 19, 2022 @ 06:10
    Dave Woestenborghs
    0

    Hi Adrian,

    It probably does noet work because the date field is not a javascript date object, but a formatted string.

    So maybe you can try this :

    Event: {{ eventTitle }} - {{ Date.parse(eventDate) | date : "dd/MM/yyyy" }}
    
  • Adriano Fabri 446 posts 1563 karma points
    May 20, 2022 @ 13:46
    Adriano Fabri
    0

    Thank you but unfortunately your code return an empty value:

    Event: 75° Festival di Cannes - 
    

    Adriano

  • Veronica 1 post 71 karma points
    6 days ago
    Veronica
    0

    Did you ever find a solution to this?

Please Sign in or register to post replies

Write your reply to:

Draft