js获取30、X天前得时间
//获取当前日期
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 LDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-"(lastD < 10 ? "0" + lastD : lastD);//得到30天前的时间