Date Formatter Documentation

Can someone point me to date formatter documentation? I looked at a couple community posts & admin code snippets but couldn’t find anything related to generic formatters - ultimately, I’m trying to configure my date content to be ‘mm/dd/yyyy’

Hey Sean! Here’s a function that should do the trick. If you want to return the month as a number (“11”) instead of long-form (“November”), just change the final return statement to "numeric".

import {
  _getDocumentLocale,
  _getProfileFieldAtKeyPath
} from './formatters-internal.js';

export function longDate(profile, keyPath) {
  const dateString = _getProfileFieldAtKeyPath(profile, keyPath);
  if (!dateString) {
    return '';
  }
  const parsedDateString = dateString + 'T00:00:00';
  const date = new Date(parsedDateString);
  const locale = _getDocumentLocale();
  if (!dateString) {
    return '';
  } else {
    return {
      day: date.toLocaleString(locale, {day: 'numeric'}),
      month: date.toLocaleString(locale, { month: 'long'}),
      year: date.toLocaleString(locale, {year: 'numeric'}),
    }
  }
}

This function returns an object with three components: “day”, “month” and “year”. You can then call the function and reference each of the components when concatenating them together. For example:

subtitle: profile.c_startDate ? Formatter.longDate(profile, "c_startDate").month + " " + Formatter.longDate(profile, "c_startDate").day + ", " + Formatter.longDate(profile, "c_startDate").year : null,