怎么使用Javascript获取距今n天前的日期
- 网页设计
- 关注:2.78W次
复制代码 代码如下:
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