countDays /** * @param {number} days - 要倒退的天数 * @returns {array} */function countDays (days) {if(days == '' || days == null || days == undefined || typeof days != "number"){return false;}var res = [];//返回数据var today = ne
/** * @param {number} days - 要倒退的天数 * @returns {array} */ function countDays (days) { if(days == '' || days == null || days == undefined || typeof days != "number"){ return false; } var res = [];//返回数据 var today = new Date().getTime();//今天 for(var i = 0; i < days; i++){ var _day = new Date(today - 86400000 * i), year = _day.getFullYear(), month = (_day.getMonth() + 1), day = _day.getDate(); month = month < 10 ? '0' + month : month; day = day < 10 ? '0' + day : day; res.push( year + '-' + month + '-' + day); } return res; }