toFormattedString method

String toFormattedString()

Returns a formatted date string (e.g., "January 15, 2024").

Example:

DateTime(2024, 1, 15).toFormattedString();
// 'January 15, 2024'

Implementation

String toFormattedString() {
  const months = [
    'January', 'February', 'March', 'April', 'May', 'June',
    'July', 'August', 'September', 'October', 'November', 'December'
  ];
  return '${months[month - 1]} $day, $year';
}