dateInWords function

String dateInWords (
  1. DateTime date
)

Returns the given DateTime's date in words (ex. 'January 19, 2019').

Implementation

String dateInWords(DateTime date) {
  String dateInWords = "";
  Map<int, String> months = {
    1: "January",
    2: "February",
    3: "March",
    4: "April",
    5: "May",
    6: "June",
    7: "July",
    8: "August",
    9: "September",
    10: "October",
    11: "November",
    12: "December"
  };
  dateInWords = months[date.month] +
      " " +
      date.day.toString() +
      ", " +
      date.year.toString();
  return dateInWords;
}