如何在 momentjs 中显示当前月份和上个月的月份名称的动态日期?

How to show dynamic dates with month name of current month and previous month in momentjs?

如何在 moment.js 中获取当前和上个月的所有日期? 我能够得到月份但无法找到月份的日期 下面的代码如果用于获取月份是否也有类似的代码用于获取日期?

var labels = moment.monthsShort();

我想展示类似的东西 this image

//sample to display february days
var months = moment.monthsShort();

var datesofmonth = createAllDatesOfMonth(months[1], 2021)

console.log(datesofmonth);


function createAllDatesOfMonth(month, year) {
  let year_month = year + "-" + month;
  let nbdays = moment(year_month, "YYYY-MMM").daysInMonth();
  return Array.from(Array(nbdays).keys()).map((d) => month + " " + (d + 1));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"></script>