var date = new Date(); date.setDate(date.getDate() - 3);//获取3天前的日期 var year = date.getFullYear(); var month = date.getMonth() + 1; if( month <10){ month = '0' + month; } var day = date.getDate(); if( d < 10){ day = '0' + day; } var time = year + "-" + month + "-" + day;