我想检查当前时间是否在JQuery中10.30AM到11.30AM之间。我如何以正确的方式做到这一点?比较JQuery中给定时期之间的当前时间
我试图通过以下方式和它并不像我想象的
function compareTime(){
var d = new Date(), // current time
hours = d.getHours(),// current hour
mins = d.getMinutes(); // current minute
var sTime = "10.30";
var eTime = "11.30";
var cTime = hours+'.'+mins;
if(sTime < cTime < eTime){
// here i want to do something if the current time is in between ...
}else{
}
}
为什么选jQuery?这是你通常用“普通”JS做的事情。 – nnnnnn
@nnnnnn JQuery是跨浏览器兼容和轻量级的原因 – Swarne27
我爱jQuery,但我所说的是它并不打算帮助你解决这类问题。 – nnnnnn