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");
}
时间: 2024-10-27 09:55:32