怎麼使用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/zh-tw/sjzz/sjzz/4vrx36.html