-1

How would I format the date returned to be displayed with the day and month eg 23 AUG with my code.

 var finaldate;

  void callDatePicker() async {
    var order = await getDate();
    setState(() {
      finaldate = order;
    });
  }

  Future<DateTime> getDate() {
    return showDatePicker(
      context: context,
      initialDate: DateTime.now(),
      firstDate: DateTime(2020),
      lastDate: DateTime(2025),
Text('$finaldate',
SK1dev
  • 1,049
  • 1
  • 20
  • 52
  • Does this answer your question? [How do I format a date with Dart?](https://stackoverflow.com/questions/16126579/how-do-i-format-a-date-with-dart) – Christopher Moore Jun 28 '20 at 00:14

1 Answers1

1

You can use DateFormat from the intl package

DateFormat('dd MMM, yyyy').format(finaldate) // gives 27 Jun, 2020
JideGuru
  • 7,102
  • 6
  • 26
  • 48