if(orderTime+7天>当前时间){
alert("订单时间已超过退差价范围!");
window.close();
}
如何让我获取到的orderTime能加上7天,和当前的时间比较呢,格式都要 yy-MM-dd
if(orderTime+7天>当前时间){
alert("订单时间已超过退差价范围!");
window.close();
}
如何让我获取到的orderTime能加上7天,和当前的时间比较呢,格式都要 yy-MM-dd
<script type="text/javascript">
function AddDays(date,days){
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 strAdded = AddDays(str,7);
var curDate = calDays(new Date(),0);
if(strAdded>curDate){
alert("大于");
}else{
alert("不大于");
}
</script>