话不多说上代码:
//离下一个圣诞节还有多少天
var christ=new Date();
christ.setMonth(11);
christ.setDate(25);
var year=now.getFullYear();
var diff=christ-now;
var time;
if(diff<0){
christ.setFullYear(year+1);
diff=christ-now;
}
time=Math.ceil(1.0*diff/(1000*3600*24));
document.write("离下一个圣诞节还有:"+time+"天");