toDDMMMMYYYY method

String toDDMMMMYYYY()

Formats the DateTime object to a string in the format dd MMMM, yyyy.

Example:

DateTime now = DateTime.now();
String formattedDate = now.toDDMMMMYYYY();
print(formattedDate); // Output: 12 July, 2024

Implementation

String toDDMMMMYYYY() {
  final day = this.day.toString().padLeft(2, '0');
  final month = _monthName(this.month);
  final year = this.year.toString();
  return '$day $month, $year';
}