flutterdatetimedart

How get the name of the days of the week in Dart


Somebody knows how can I extract from DateTime the name of the day of the week?

ej:

DateTime date = DateTime.now();
String dateFormat = DateFormat('dd-MM-yyyy hh:mm').format(date);

Result -> Friday


Solution

  • Use 'EEEE' as a date pattern

     DateFormat('EEEE').format(date); /// e.g Thursday
    

    or

     DateFormat.EEEE().format(date);
    

    Don't forget to import

    import 'package:intl/intl.dart';
    

    Check this for more info : https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html