I have a repeater that is displaying data from a collection, including a text box that is linked to a date field. The date is displayed in the following format :
and I would like it to only show, the “Wed Dec 13 2017” part.
There’s no built in way to do it, but you can easily do so by code.
Let’s say you have the date on a variable called ‘originalDate’ something like that:
Hi Liran,
I’m afraid I agree with GCC, my code is not working either. I tried implementing it on a text that is not within a repeater but still doesn’t do anything.
You can also use a Date Picker element to display dates without the time.
If your Dataset mode is set to “Read-only,” the Date Picker element will display the date but will not be clickable, so it will not display the calendar part of the element.
Hey DellaJean,
If you look at the code shared,
On the first line is the regular onReady, and on the second line there’s another onReady function.
$w("#photoData").onReady ( () => {
This is the dataset onReady Function. #photoData is the property name of my dataset. So adding this into the code makes sure that the dataset has been fully loaded before executing the code.
The first onReady doesn’t execute the code until the page is loaded the dataset onReady doesn’t execute the code until the dataset is loaded.
So in the code I shared in a few comments above, it says on Page Ready, make sure dataset is fully loaded, then execute the code.
You’re most welcome! I’m no genius, it took me days to figure that little treasure out! Now when code doesn’t work as expected (involving datasets), I always add a dataset onReady to see if that fixes it.
Hey there, I came across a little snag with the code I posted earlier. If you limit the amount of items shown using the manage dataset options, then use the connect button feature to “load more” (and possibly the next/prev actions too, not tested), it will not execute the date formatting code on the newly loaded items.
I fixed this by changing this line;
$w("#repeater1").forEachItem( ($w) => {
to this;
$w("#repeater1").onItemReady( ($w) => {
so that the will code execute for each item as it finishes loading.