datetime_format library
Locale-sensitive date and time formatting.
Use the DateTimeFormat class to format dates and times in a locale-sensitive manner.
import 'package:intl4x/datetime_format.dart';
void main() {
final timeZone = 'Europe/Paris';
final dateTime = DateTime.parse('2024-07-01T08:50:07');
final formatter = DateTimeFormat.yearMonthDayTime(
locale: Locale.parse('en'),
length: DateTimeLength.long,
).withTimeZoneShort();
print(
formatter.format(dateTime, timeZone),
); // prints 'July 1, 2024 at 8:50:07 AM GMT+2'
}
The formatters are
- DateTimeFormat.day
- DateTimeFormat.month
- DateTimeFormat.monthDay
- DateTimeFormat.monthDayTime
- DateTimeFormat.year
- DateTimeFormat.yearMonthDay
- DateTimeFormat.yearMonthDayTime
- DateTimeFormat.yearMonthDayWeekday
- DateTimeFormat.yearMonthDayWeekdayTime
- DateTimeFormat.time
and the zoned variants through
Classes
- DateTimeFormat
-
DateTimeformatting. - 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.