Skip to main content
Version: 0.2.0

Formatting

Format a DateTime with an intl pattern, plus two extras: do for the day of the month with its ordinal suffix (1st, 2nd, 1er, 2.) and [...] for literal text. Literal text in intl quotes ('at') works too.

Pattern formatting​

DateTime.format and FlutterDateFormatter.format give the same result. A FlutterDateFormatter can be kept and reused for any number of dates.

LOADING…
⚙ TRY IT
⚡ OUTPUT
final date = DateTime(2026, 10, 7, 5, 30, 52);

date.format(pattern: 'do MMMM yyyy', locale: 'en');

// or keep one formatter and reuse it
final formatter = FlutterDateFormatter('do MMMM yyyy', 'en');
formatter.format(date);

Ordinal numbers​

FlutterDateFormatter.ordinal and formatOrdinalNumber follow the rules of each locale.

LOADING…
⚡ OUTPUT
FlutterDateFormatter.ordinal(21, locale: 'en');
date.formatOrdinalNumber(locale: 'en'); // day of the month

Date ranges​

LOADING…
⚙ TRY IT
⚡ OUTPUT
final start = DateTime(2025, 3, 1);
final end = DateTime(2025, 3, 5);

start.formatRange(
end,
locale: 'en',
);

Use formatRange for a localized range with the locale's default date pattern. The optional pattern uses the same syntax as format, including ordinal days and literal text.

final start = DateTime(2025, 3, 1);
final end = DateTime(2025, 3, 5);

start.formatRange(end); // Mar 1–5, 2025
start.formatRange(end, locale: 'vi');
start.formatRange(end, pattern: 'do MMMM yyyy');

The equivalent static API is FlutterDateFormatter.formatDateTimeRange(start, end). Endpoints in the same month and year are compacted when using the default pattern; endpoints on the same calendar day are formatted once. An end before the start throws an ArgumentError.

Pattern cheat sheet​

TokenMeaning
doDay with ordinal suffix: 1st, 2nd (package extension)
[text]Literal text, e.g. [Today is] EEEE (package extension)
'text'Literal text, as in intl: dd/MM/yyyy 'at' HH:mm; '' is an apostrophe
d / ddDay of month: 5 / 05
E / EEEEWeekday: Wed / Wednesday
M / MM / MMM / MMMMMonth: 3 / 03 / Mar / March
y / yy / yyyyYear: 2025 / 25 / 2025
Q / QQQ / QQQQQuarter: 1 / Q1 / 1st quarter
H / HH, h / hhHour 0-23, hour 1-12
m / mm, s / ssMinutes, seconds
aAM/PM marker
yMd, yMMMd, jm, Hm …intl skeletons: locale-aware formats
Regions are kept

format(pattern: 'yMd', locale: 'en_GB') gives 04/03/2025, while en_US gives 3/4/2025. Locale codes are case-insensitive and accept BCP-47 tags such as pt-BR.