formatDateTime static method

String formatDateTime({
  1. DateTime? dateTime,
  2. String? pattern,
})

dateTime 转 字符串 DateTime() => yyyy-MM-dd HH:mm:ss

Implementation

static String formatDateTime({DateTime? dateTime, String? pattern}) {
  if (dateTime == null) dateTime = DateTime.now();
  if (pattern == null) pattern = full;
  return DateFormat(pattern).format(dateTime);
}