//获取上一个月最后一天的日期
lastDate = function(date){
var day = date.getDate() > 9?(date.getDate()-1):"0" + (date.getDate()-1);
var month = (date.getMonth() + 1) > 9?(date.getMonth() + 1):"0"+(date.getMonth() + 1);
return date.getFullYear() + month + day;
}
1 //获取上一天的日期 2 formatterDate = function(date){ 3 var year = date.getFullYear(); 4 var month = (date.getMonth() + 1) > 9?(date.getMonth()):"0"+(date.getMonth()); 5 var day = new Date(year,month,0); 6 return date.getFullYear() + month + day.getDate(); 7 8 }
调用方式:
$('#cjrq').datebox('setValue',formatterDate(new Date()));