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 469 posts 1633 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 3504 posts 12135 karma points MVP 9x 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 469 posts 1633 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 3504 posts 12135 karma points MVP 9x 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 469 posts 1633 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
    Nov 22, 2022 @ 14:18
    Veronica
    0

    Did you ever find a solution to this?

  • Adriano Fabri 469 posts 1633 karma points
    Dec 10, 2022 @ 14:29
    Adriano Fabri
    0

    Hi, sorry for delay.

    Unfortunately I haven't found a solution yet

  • Angel 54 posts 111 karma points
    Dec 02, 2022 @ 19:30
  • Adriano Fabri 469 posts 1633 karma points
    Dec 10, 2022 @ 14:29
    Adriano Fabri
    1

    This is a good news...I'll try this solution

    Thank you Adriano

  • Gulshan Negi 1 post 71 karma points
    Dec 13, 2022 @ 12:44
    Gulshan Negi
    0

    Hi please look at here https://docs.angularjs.org/api/ng/filter/date. You must try this steps.

  • npack 51 posts 297 karma points
    Jul 15, 2024 @ 19:13
    npack
    0

    I am having the same troubles. Anybody have any other suggestions?

    {{eventDate}}
    

    outputs

    "2024-03-13 00:00:00"

    {{eventDate | date:"MM/dd/yyyy"}}
    

    outputs "2024-03-13 00:00:00"

    {{Date.parse(eventDate) | date:"MM/dd/yyyy"}}
    

    outputs ""

    {{eventDate | momentDateTimeZone:"MM/dd/yyyy"}}
    

    throws an exception

Please Sign in or register to post replies

Write your reply to:

Draft