firstDayOfMonth method

String firstDayOfMonth({
  1. String? format,
  2. String? locale,
})

Returns the first day of the month from the provided DateTime in String format.

If the date is in DateTime format, you can convert it to String DateTime().toString().

You can provide the locale to filter the result to a specific language.

Defaults to 'en-US'.

Example

String date = '2021-10-23';
String day = date.firstDayOfDate(); // returns 'Friday'
String grDay = date.firstDayOfDate(locale:'el'); // returns 'Παρασκευή'

Implementation

String firstDayOfMonth({String? format, String? locale}) {
  if (isBlank) {
    return blankIfNull;
  }
  return toDate(format, locale).firstDayOfMonth.format('EEEE');
}