后台时间计算问题
现在在做会议室预约功能,用色块代表时间段 现在遇到一个计算时间的问题!用当前时间(A)+可预约的天数(比如传来的天数是7)(B)=可预约的天数(C),这个计算出来的是可预约时间(可预约的色块我让它是红色)C得到的是从当前时间到传来的天数7 算出这7天可以预约 7天以后的就不能预约了,让色块变成绿色, 怎么计算 ?怎么判断?
[解决办法]
其实页面样式控制跟判断都不难!!!
主要的在于你的可预约的天数
这个会议室资源可是要时时更新的、也许你在判断的那一刻、这个资源就被别人预定占用了!
先撇开这些不说:
用JS计算当前时间加上天数(可预约时间)
var newDate = new Date();// 现在时间
var the_year = nowTime.getYear();
var the_month = nowTime.getMonth() + 1;
var the_day = nowTime.getDate()+7; //7为可预约天数
newDate = new Date(the_year,the_month,the_day);
var newDate = new Date();// 现在时间
var the_year = nowTime.getYear();
var the_month = nowTime.getMonth() + 1;
var the_day = nowTime.getDate();
for(var i = 1 ;i <= 7(可预约天数) ; i++){
the_day = nowTime.getDate() + i ;
document.getElementById(the_year+the_month+the_day).style.backgroundColor = "red";
}