javascript取当月最后一天

<!--javascript取当月最后一天-->
<script   language=javascript>  
  var current = new Date();
  var year = current.getYear();
  var month = current.getMonth();
  showMonthLastDay(year, month);
 
  function   showMonthLastDay(year,month)   
  { 
	alert("year:"+year+", month:"+month);
	year = ( year < 1900 ) ? ( 1900 +year ) : year;
	var tempDate = new Date();
	tempDate.setYear(year);
	tempDate.setMonth(month+1);
	tempDate.setDate(0);
	var tempYear = tempDate.getYear();
	tempYear = ( tempYear < 1900 ) ? ( 1900 +tempYear ) : tempYear;

	alert("本月最后一天:"+tempYear+"-"+(tempDate.getMonth()+1)+"-"+tempDate.getDate());  
  }   
</script>

你可能感兴趣的:(JavaScript)