@atom-forge/date-format · Presentation
Date Format uses the runtime’s Intl.DateTimeFormat support to display dates through a small token interface. It is built for presentation, not for date arithmetic or parsing user input.
What it is
dateFormat(format, date?, lang?, timeZone?) returns a string. The date defaults to now and the language to en-GB; pass a timezone when the output must not depend on the viewer’s location.
Percent tokens produce numbers (%Y, %M, %D, %H, %I, %S) and dollar tokens produce localized names (month, weekday, day period, timezone).
Month names, weekdays and timezone labels come from Intl, so they follow the locale you ask for.
A short format string replaces a chain of option objects.
Fix the instant, locale and zone, and the output is reproducible.
Keep an unambiguous timestamp; format only when you present it.
Use the same values on the server and the client to avoid hydration differences.
Combine numeric and text tokens, for example %Y-%M-%D or $D, %D $M %Y.
An honest fit check
They are not Moment-style YYYY or date-fns patterns. %M is the padded month; use %I for minutes.
Localized names and punctuation vary with the runtime’s Intl data, so avoid brittle tests on them.
A fixed timestamp and timezone make the numeric output reproducible.
import { dateFormat } from '@atom-forge/date-format';
const instant = new Date('2026-04-07T06:05:03Z');
const zone = 'Europe/Budapest';
dateFormat('%Y-%M-%D', instant, 'en-GB', zone); // 2026-04-07
dateFormat('%H:%I:%S', instant, 'en-GB', zone); // 08:05:03