js获取当前月的天数

function calcDate(month){  //  计算当月天数 不需要+1  按正常月份传参
  var oDate = new Date();
  oDate.setDate(1)  //设置当月 日数 为1
  oDate.setMonth(month) //设置月数
  oDate.setDate(0)  //把日期设置上个月最后一天
  let dayLength = oDate.getDate();
  //log( oDate.getMonth()+1 + '月' + "天数"+oDate.getDate())
  return  dayLength;
}
原文地址:https://www.cnblogs.com/ksunone/p/8378298.html