datetime_format library

Locale-sensitive date and time formatting.

Use the DateTimeFormat class to format dates and times in a locale-sensitive manner.

final timeZone = 'Europe/Paris';
final dateTime = DateTime.parse('2024-07-01T08:50:07');
final formatter = DateTimeFormat.yearMonthDayTime(
  locale: Locale.parse('en'),
  length: DateTimeLength.long,
).withTimeZoneLong();
print(
  formatter.format(dateTime, timeZone),
); // July 1, 2024 at 8:50:07 AM Central European Summer Time

The formatters are

and the zoned variants through

Classes

DateTimeFormat
DateTime formatting.
DateTimeFormatter
Formatters that can format a DateTime with time zone information.
DateTimeFormatterStandalone
A base class for formatters that can format a DateTime into a string.
Locale
Representing a Unicode locale identifier.
ZonedDateTimeFormatter
A base class for formatters that can format a DateTime and time zone string into a string.

Enums

Calendar
Calendar types for date and time formatting.
ClockStyle
Clock styles for hour formatting.
DateTimeAlignment
Alignment of date/time formatting.
DateTimeLength
Length of date/time formatting.
NumberingSystem
Numbering systems for number formatting.
TimePrecision
Precision of time formatting.
TimeZoneType
Types of time zone formatting.
YearStyle
Styles for formatting the year component of a date.

Extensions

EnumComparisonOperators on TimePrecision
Provides comparison operators for TimePrecision enum values.