How for I change the event start date date format from yyyy/mm/dd HH:mm sm/pm to mm/dd/yyyy hh:mm am/pm
This is located in Text3 and is the top date on the repeater
it looks so ugly on the link below.
https://www.royalsynergyproductions.com/test
import {retrieveEvents} from 'backend/eventapi';
$w.onReady(function () {
$w("#EventRepeater").hide();
let suggestions = [];
let item = [];
retrieveEvents().then(function(resp) {
let predictions = resp.events;
predictions.forEach(function(event, index) {
if(index < 3) {
item = {
"_id" : event.id,
"eventname" : event.name.text,
"eventdescription": event.description.text,
"eventlink" : event.url,
"eventStart" : event.start.local,
"eventEnd" : event.end.local,
"eventImg" : event.logo.url
};
suggestions.push(item);
}
});
$w("#EventRepeater").data = suggestions;
});
$w("#EventRepeater").onItemReady(($w, itemData, index) => {
const text1 = $w("#text2");
text1.text = itemData.eventname;
const text2 = $w("#text1");
let str1 = String(itemData.eventdescription);
let strLength = 180;
if(str1.length > strLength) {text2.text = itemData.eventdescription.slice(0, strLength);} else { text2.text = itemData.eventdescription;}
const button2 = $w("#button2");
button2.link = itemData.eventlink;
const text3 = $w("#text3");
text3.text = itemData.eventStart.format('dddd Do MMMM YYYY, h:mm a').split('T').splice(0, 4).join(' @ ');
const text4 = $w("#text4");
text4.text = itemData.eventEnd.split('T').splice(0, 4).join(' @ ');
const image1 = $w("#image1");
image1.src = itemData.eventImg;
$w("#EventRepeater").show();
});
});
Hi,
Try this:
const date = itemData.eventStart.split('T')[0].split('-'); const yourFormat = `${test[1]}/${test[2]}/${test[0]}`;
Good luck!
Roi.