Posted in Javascript onJuly 08, 2013
function Test(day) { var today = new Date(); var beforMilliseconds = today.getTime() - 1000 * 3600 * 24 * day; var beforday = new Date(); beforday.setTime(beforMilliseconds); var strYear = beforday.getFullYear(); var strDay = beforday.getDate(); var strMonth = beforday.getMonth() + 1; if (strMonth < 10) { strMonth = "0" + strMonth; } var strYesterday = strYear + "-" + strMonth + "-" + strDay; alert(strYesterday); }
如何使用Javascript获取距今n天前的日期
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@