dateFormatDatetime static method

String dateFormatDatetime({
  1. required String? date,
  2. String? content,
})

Implementation

static String dateFormatDatetime({required String? date, String? content}) {
  try {
    if (date?.isNotEmpty == true) {
      var time = date?.split("+");
      initializeDateFormatting("vi_VN");
      var inputFormat = DateFormat("yyyy-MM-dd'T'HH:mm:ss", "vi_VN");
      var inputDate = inputFormat.parse(time![0]);
      var outputFormat = DateFormat('hh:mm a', "vi_VN");
      var outputDate = outputFormat.format(inputDate);
      return outputDate.toUpperCase();
    } else {
      return "$content";
    }
  } catch (e) {
    return "$content";
  }
}