当前位置:学者斋 >

设计制作 >网页设计 >

怎么使用Javascript获取距今n天前的日期

怎么使用Javascript获取距今n天前的日期

复制代码 代码如下:

怎么使用Javascript获取距今n天前的日期

function Test(day) {

var today = new Date();

var beforMilliseconds = ime() - 1000 * 3600 * 24 * day;

var beforday = new Date();

ime(beforMilliseconds);

var strYear = ullYear();

var strDay = ate();

var strMonth = onth() + 1;

if (strMonth < 10) {

strMonth = "0" + strMonth;

}

var strYesterday = strYear + "-" + strMonth + "-" + strDay;

alert(strYesterday);

}

  • 文章版权属于文章作者所有,转载请注明 https://xuezhezhai.com/sjzz/sjzz/4vrx36.html