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
- 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.