I suspect that the following will be much easier in a repeater, but I’d prefer not to have to build it all myself.
I’m following the instructions here ( https://support.wix.com/en/article/wix-code-how-to-format-dates#additional-formatting-options-1 ) to format a date on my site here ( https://www.davidaronchick.com/ ).
However, unlike this example, I’d like to format every date in the row in my dataset, rather than just one element on the page. Should I use an afterQuery code hook?
Something like this?
export function AllData_afterQuery(item, context) {
item.date = item.date.toString("foo bar formatting string");
return item;
}
You can format the date in a repeater like this…
$w(“#repeater1”).forEachItem(($w) => {
//get the original date format from the repeater date text
let originalDate = $w(“#repeaterDateText”).text;
//re-format the original date
let newDate = originalDate.split(’ ‘).splice(1, 3).join(’ ');
//set the new date format for the repeater date text
$w(‘#repeaterDateText’).text = newDate;
})
Right, but I was hoping to avoid using a repeater because the table just makes it very convenient.
Did you ever get this sorted? I have the same issue of formatting a date from a dataset into a table, but have not managed it. Most of the advice on here seems to refer to formatting into repeaters or onto a page. But not into a table! V frustrating…