Display future dates in the Website Builder
The best way to do this, so you can always use it anywhere in the platform, is to setup a NodeJS flow in the automation builder, which updates Global Variables, then use those global variables in the site builder.
1. Create 5 Global Variables. For today's date use the below. For future dates use +X at the end. E.g. DD+3
DD
Day
MM
Month
YYYY
2. Use the below code in a NodeJS step in the automation builder.
exports.handler = async (event) => {
const dayOffset = 0; // Adjust days forward or backward. 0 = today, 1 = tomorrow, -1 = yesterday
const getFormattedDatesForTimezones = () => {
const utcNow = new Date(); // Current UTC time
utcNow.setDate(utcNow.getDate() + dayOffset); // Apply day offset
const monthNames = [
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
const formatDate = (date) => {
const day = String(date.getDate()).padStart(2, '0');
const dayName = date.toLocaleDateString('en-US', { weekday: 'long' });
const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are zero-based
const monthName = monthNames[date.getMonth()];
const year = date.getFullYear();
return {
"DD": day,
"Day": dayName,
"MM": month,
"Month": monthName,
"YYYY": year
};
};
const timezoneLabels = {
"UTC-12": "IDLW",
"UTC-11": "SST",
"UTC-10": "HST",
"UTC-9": "AKST",
"UTC-8": "PST",
"UTC-7": "MST",
"UTC-6": "CST",
"UTC-5": "EST",
"UTC-4": "AST",
"UTC-3": "ART",
"UTC-2": "GST",
"UTC-1": "AZOT",
"UTC+0": "UTC",
"UTC+1": "CET",
"UTC+2": "EET",
"UTC+3": "MSK",
"UTC+4": "GST",
"UTC+5": "PKT",
"UTC+6": "BST",
"UTC+7": "ICT",
"UTC+8": "CST",
"UTC+9": "JST",
"UTC+10": "AEST",
"UTC+11": "AEDT",
"UTC+12": "NZST"
};
const results = {};
// Generate formatted dates for all 24 timezones (-12 to +12)
for (let offset = -12; offset <= 12; offset++) {
const localDate = new Date(utcNow.getTime() + offset * 60 * 60 * 1000);
const timezone = `UTC${offset >= 0 ? "+" : ""}${offset}`;
const label = timezoneLabels[timezone] || timezone;
const formattedDate = formatDate(localDate);
results[label] = formattedDate;
}
return results;
};
// Get today's date in multiple timezones and formats
const timezoneDates = getFormattedDatesForTimezones();
// Construct response
const response = {
statusCode: 200,
body: JSON.stringify(timezoneDates),
};
return response;
};
The days offset at the top is how you set the number of days in future.
Once you've added the NodeJS step, then add a "Wait for amount of time" step and loop it back to the beginning of the NodeJS step.
Inside the "Wait" step, choose "Wait till specific week day" and select all days. Make the specific time 12 midnight.
Go back to the NodeJS step and make sure you "Save Output Response" as global variables.
The way to do this is to "Run Test" on the code, which will produce a huge response with different dates and times for every different timezone around the world.
Find the right timezone for you, and use the 3-4 digit timezone code in front of the Global Variable Value.
If you needed EST or UTC instead of PTC, you would just change the PST at the front of the "Response Key To Save".
Save the NodeJS step, save the flow, and create a new "Dates" contact, that you'll just put into this flow (and they'll never leave it). Every day at midnight in your timezone, the contact will pull the correct info into your Global Variable fields which you can then use in the site builder by following this short walkthrough.
Use Global Variables In Site Builder
The good news is, once you've done this, even though it takes 5 or so minutes, you'll be able to use the merge fields all over the platform for emails etc forever more.