formatTimestampInMilliseconds function

Future<String> formatTimestampInMilliseconds({
  1. required int timestamp,
  2. bool use24HourFormat = false,
  3. String languageCode = 'en',
  4. bool showTime = true,
  5. String? countryCode,
  6. bool isUtc = false,
})

Formats a timestamp in milliseconds since epoch into a date string.

The timestamp must be positive, and this function supports all options provided by formatDateTime.

Implementation

Future<String> formatTimestampInMilliseconds({
  required int timestamp,
  bool use24HourFormat = false,
  String languageCode = 'en',
  bool showTime = true,
  String? countryCode,
  bool isUtc = false,
}) async {
  if (timestamp < 0) {
    throw ArgumentError('timestamp must be a positive integer');
  }

  return formatDateTime(
    DateTime.fromMillisecondsSinceEpoch(timestamp, isUtc: isUtc),
    use24HourFormat: use24HourFormat,
    languageCode: languageCode,
    countryCode: countryCode,
    showTime: showTime,
  );
}