日期:2014-05-16  浏览次数:20371 次

js获取昨天的日期

function getYestoday(){????
???var date = new Date();
???? ?var yesterday_milliseconds=date.getTime()-1000*60*60*24;??????????
???? ?var yesterday = new Date();??????????
???????? yesterday.setTime(yesterday_milliseconds);??????????
????????????
???? ?var strYear = yesterday.getFullYear();???????
???? ?var strDay = yesterday.getDate();???????
???? ?var strMonth = yesterday.getMonth()+1;?????
???? ?if(strMonth<10){???????
???????? strMonth="0"+strMonth;???????
???? ?}???????
???? ?datastr = strYear+"-"+strMonth+"-"+strDay;?????
???? ?return datastr;?????
??}?????