複製代碼 代碼如下:
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);
}