js獲取30天前的某天
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth()+1;
var day = date.getDate();
var nowDate = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
//獲取30天前得日期
var lastDate = new Date(date - 1000 * 60 * 60 * 24 * 30);//最後30天可以更改,意義:是獲取多少天前的時間
var lastY = lastDate.getFullYear();
var lastM = lastDate.getMonth()+1;
var lastD = lastDate.getDate();
var lastDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-"+(lastD < 10 ? "0" + lastD : lastD);//得到30天前的時間