Date formatting using locale in Forge UI

In my Forge UI application I render dates as ISO dates, but would like to improve this to use the standard Jira date representation.

eg. in Releases tab dates are rendered as “March 1, 2023” (Englisch) or “1 mars 2023” (French).

How can I implement this is my Forge app? I know I can get locale from view.getContext(), but how to combine with date formatting options?

Also look and feel can be changed by Jira admin? How about getApplicationProperty for jira.lf.date.dmy? Or can I ignore this?

BR, Holger

You can use Intl.DateTimeFormat Intl.DateTimeFormat() constructor - JavaScript | MDN, but you need to replace “_” in context.locale with “-”.

const context = await view.getContext();
const MEDIUM_DATE = { day: "numeric", month: "long", year: "numeric" };

Intl.DateTimeFormat( context.locale.replace('_','-'), MEDIUM_DATE).format(new Date( mydatefield ))
2 Likes