I am still very new to this. I tried the following code, which works but doesn’t. There are two issues here.
First, it takes literally 10-30 seconds from page load until the date areas are populated. That won’t work, as visitors will be off elsewhere long before.
Second, it formats the date as desired, but the date doesn’t change from item to item (same date in each repeated item).
Suggestions? Thanks.
//after page load
$w.onReady( function () {
// Get the date from the date field of the current item
//const classstdate = $w(“#dataset10”).getCurrentItem().startDate;
//const classendate = $w(“#dataset10”).getCurrentItem().endDate;
const wkshpstdate = $w(“#dataset8”).getCurrentItem().startDate;
const wkshpendate = $w(“#dataset8”).getCurrentItem().endDate;
const spevstdate = $w(“#dataset9”).getCurrentItem().startDate;
const spevendate = $w(“#dataset9”).getCurrentItem().endDate;
const ctastdate = $w(“#dataset7”).getCurrentItem().callBegins;
const ctaendate = $w(“#dataset7”).getCurrentItem().deadline;
// various date display configurations
const MoDa = { month: “short”, day: “numeric” }; // Jan 18
const HrMn = { hour: “numeric”, minute: “numeric” }; // 12:45
const DOW = { weekday: “long” }; // Monday
const DOWMoDa = { weekday: “long”, month: “short”, day: “numeric” }; // Monday, Jan 18
const Full = { weekday: “long”, month: “short”, day: “numeric”, hour: “numeric”, minute: “numeric” }; // Monday, Jan 18, 12:45
// Set the text element to display the date using the user’s settings
//$w(“#text36”).text = classstdate.toLocaleDateString(“en-US”, Full);
$w(“#text39”).text = wkshpstdate.toLocaleDateString(“en-US”, MoDa);
$w(“#text52”).text = wkshpendate.toLocaleDateString(“en-US”, MoDa);
//if(spevstdate !==null){
$w(“#text64”).text = spevstdate.toLocaleDateString(“en-US”, Full);
//}
//$w(“#text65”).text = spevendate.toLocaleDateString(“en-US”, Full);
$w(“#text47”).text = ctastdate.toLocaleDateString(“en-US”, MoDa);
$w(“#text49”).text = ctaendate.toLocaleDateString(“en-US”, MoDa);
});