formatTimestampEpoch method

String? formatTimestampEpoch({
  1. String targetFormat = 'dd MM yyyy',
})

Interprets the string as an epoch timestamp (milliseconds) and formats it according to targetFormat.

Implementation

String? formatTimestampEpoch({String targetFormat = 'dd MM yyyy'}) {
  if (this == null || this!.isEmpty) return null;
  final epoch = toInt();
  if (epoch == null) return null;

  final dateTime = DateTime.fromMillisecondsSinceEpoch(epoch);
  return dateTime.formatDate(targetFormat: targetFormat);
}