首页 > 代码库 > 前天,昨天和今天

前天,昨天和今天

var today=new Date();var yesterday=new Date(today.getTime()-1000*60*60*24);        var thedaybeforeyesterday=new Date(today.getTime()-1000*60*60*24*2);            var strToday=getStringFromDate(today);var strYesterday=getStringFromDate(yesterday);var strThedaybeforeyesterday=getStringFromDate(thedaybeforeyesterday); 上面用到的函数function getStringFromDate(dd){    var y = dd.getFullYear();        var m = dd.getMonth()+1;    m=parseInt(m,10);    if(m<10){        m="0"+m;    }        var d = dd.getDate();    d=parseInt(d,10);    if(d<10){        d="0"+d;    }        return y+"-"+m+"-"+d;}

 

前天,昨天和今天