formatDateTime function

Future<String> formatDateTime(
  1. DateTime dateTime, {
  2. bool use24HourFormat = false,
  3. String languageCode = 'en',
  4. bool showTime = true,
  5. String? countryCode,
})

Formats a DateTime object into a string.

Allows specifying whether to use a 24-hour format, language code, country code, and whether to show time.

Implementation

Future<String> formatDateTime(
  DateTime dateTime, {
  bool use24HourFormat = false,
  String languageCode = 'en',
  bool showTime = true,
  String? countryCode,
}) async {
  final dateFormatter = await retrieveDateFormatter(
    use24HourFormat: use24HourFormat,
    languageCode: languageCode,
    countryCode: countryCode,
    showTime: showTime,
  );

  return dateFormatter.format(dateTime);
}