I have a repeater set up to show my blog posts with the title and publication date. I connected the information to the dataset and everything is working fine. I just have a formatting preference that I’m not able to set up and would like to know if anyone knows how to do it… I chose to display the date as the short date which looks like this: 04/05/2022. I would like to replace the “/” with a “-”, to make the date be displayed as 04-05-2022. Is that possible through code?
Here’s a screenshot of the repeater and the dataset connection, in which I chose the short date format. And if you look to the repeater itself is how I would like the date to be formatted.
If it’s OK to present the date based on the UTC time zone (the date changes at 00:00 UTC). Then disconnect the dateText from the dataset , add code like this:
But I’m not sure if this alone would be the solution I’m looking for, it doesn’t have to do with the order DDMMYYYY or MMDDYYYY it has to do with the symbol that separates each part of the date, one is a “dash” (the one I want) so it would show DD-MM-YYYY instead of the other which is a “slash” (what is currently showing) DD/MM/YYYY.
@buenok you are missing a pair of parentheses arround the callback arguments: .onItemReady( ( $item, itemData ) => { …rest of the code }
($item, itemData) =>
About the slash Vs dash question, it is a Locale option, in USA it is common using the dash as a date separator. In BR it is common to use the slash separator for dates.