formatDateTime function

String? formatDateTime(
  1. String format,
  2. dynamic value
)

Formats a DateTime value using the given format pattern.

  • Accepts DateTime, int (milliseconds since epoch), or String.
  • Returns null if value is null.
  • Uses intl.DateFormat for formatting.

Implementation

String? formatDateTime(String format, dynamic value) {
  if (value == null) return null;
  final dateTime = toDateTime(value);
  return dateTime != null ? DateFormat(format).format(dateTime) : null;
}