convertDateFormat method

String convertDateFormat(
  1. String inputDate
)

Implementation

String convertDateFormat(String inputDate) {
  try {
    DateFormat inputFormat = DateFormat("dd/MM/yyyy, hh:mm a");
    DateFormat outputFormat = DateFormat("yyyy-MM-dd");

    DateTime dateTime = inputFormat.parse(inputDate);
    return outputFormat.format(dateTime);
  } catch (e) {
    print("Error parsing date: $e");
    return ""; // Return an empty string or handle error as needed
  }
}