function agomonth(x) {
var date = new Date();
date.setMonth(date.getMonth()-x);
return date.getFullYear()+'-'+(date.getMonth()+1)+'-01'
}
调用月份处理函数:时间设置为月初
agomonth(0)
"2017-1-01"
agomonth(1)
"2016-12-01"