a1007790170 于 2015.07.22 11:47 提问

if(orderTime+7天>当前时间){
window.close();
}

``````    如何让我获取到的orderTime能加上7天，和当前的时间比较呢，格式都要 yy-MM-dd
``````

3个回答

danielinbiti      2015.07.22 12:18
`````` <script type="text/javascript">
var nd = new Date(date);
return calDays(nd,days);
}
function calDays(nd,days){
nd = nd.valueOf();
nd = nd + days * 24 * 60 * 60 * 1000;
nd = new Date(nd);
//alert(nd.getFullYear() + "年" + (nd.getMonth() + 1) + "月" + nd.getDate() + "日");
var y = nd.getFullYear();
var m = nd.getMonth()+1;
var d = nd.getDate();
if(m <= 9) m = "0"+m;
if(d <= 9) d = "0"+d;
var cdate = y+"-"+m+"-"+d;
return cdate;
}
var str='2015-06-22';
var curDate  = calDays(new Date(),0);
}else{
}
</script>
``````
caozhy      2015.07.22 13:05
showbo      2015.07.22 15:24
``````
function OverDate(s, days) {
s = '20' + s;
var d = new Date(s.replace(/-/g, '/')), now = new Date();
now = new Date(now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate());//去掉时间部分
d.setDate(d.getDate() + days);
return d.getTime() > now.getTime();
}