自定义方法,用于获取本月或指定月份的最后一天,如果不传参数,就是当前月:

function getMonthFinalDay(year,month){
	var day='';
	if(year==null || year==undefined || year==''){
		year = new Date().getFullYear();
	}
	if(month==null ||  month==undefined || month==''){
		month = new Date().getMonth()+1;
	}
	day = new Date(new Date(year,month).setDate(0)).getDate();
	return year+"-"+month+"-"+day;
	
}

 调用方式:

getMonthFinalDay();//2017-10-31
getMonthFinalDay(2016);//2016-10-31
getMonthFinalDay(2017,9);//2017-9-30

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
相关资源
相似解决方案