I am building a confluence macro that returns a date in date format. I generate the date format by using the AdfRenderer from @forge/react like this:
import React, { useEffect, useState } from 'react';
import ForgeReconciler, {
AdfRenderer,
useConfig,
Label,
useProductContext,
DatePicker,
Text
} from '@forge/react';
const today = new Date().toISOString().split('T')[0];
const toTimestamp = (dateString) => {
if (!dateString) return Date.now().toString();
const d = new Date(dateString);
return isNaN(d.getTime()) ? Date.now().toString() : d.getTime().toString();
};
const Config = () => {
return (
<>
<Label>Define date</Label>
<DatePicker
name="datepicker"
isRequired
defaultValue={today}
/>
</>
);
};
const App = () => {
const config = useConfig();
const dateValue = config?.datepicker;
const timestamp = toTimestamp(dateValue);
// Always render the REAL ADF in view mode
const actualADF = {
type: "doc",
version: 1,
content: [
{
type: "paragraph",
content: [
{
type: "date",
attrs: { timestamp: timestamp }
}
]
}
]
};
return (
<>
<AdfRenderer document={actualADF}
/>
</>
);
};
ForgeReconciler.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// UI Kit config registration
ForgeReconciler.addConfig(<Config />);
Everything works well, except for the problem that the rendered data is always in MMM DD, YYYY format (e.g., Feb 10, 2026). I have tried changing the global date configuration in Confluence, my Atlassian account’s language, my browser’s language, but all had no effect. Only the built-in date macro in Confluence changed as my configuration changed, but the value as rendered by the Forge macro stays the same no matter what I do.
Could someone please advise how I can get the rendered date in the format of DD.MM.YYYY for example?
Thank you very much!