获取时间段

var aa = checkTime (["15:50", "20:40"]);

if(aa){

alert('下午3:50-8:40期间内限制申请');
return false;
}

function checkTime(ar) {
var d = new Date();
var current = parseInt(d.getHours()) * 60 + parseInt(d.getMinutes());
var ar_begin = ar[0].split(':');
var ar_end = ar[1].split(':');
var b = parseInt(ar_begin[0]) * 60 + parseInt(ar_begin[1]);
var e = parseInt(ar_end[0]) * 60 + parseInt(ar_end[1]);
console.log('开始'+b);console.log('结束'+e);console.log('现在'+current);
if ((current > b) && (current < e))
{
//console.log(123);
return true;

}
else
{
//console.log(456);

return false;

//console.log(456555);
}

}

猜你喜欢

转载自www.cnblogs.com/gyc51/p/9456875.html