标签:function
function gM(num) {
var new_month = 0;
var now_date = new Date();
var year = now_date.getFullYear();
var month = now_date.getMonth();
if ((month - num) < 0) {
for (var i = 1; i < 100; i++) { //此处为最大100年以内判断
var new_month = new_month + 12;
if (((new_month + month) - num) > 0) {
var new_year = year - Number(i);
var new_month = (new_month + month) - num;
break;
};
};
} else {
var new_year = year;
var new_month = month - num;
}
return (new_year.toString() + "-" + new_month.toString() + "-" + "1" + " 00:00:00");
}
标签:function
原文地址:http://314258.blog.51cto.com/304258/1828954