如果当前时间符合以下情况之一,我需要运行特定的逻辑:
- 早于上午7点
- 在上午7点至9点之间
- 在上午9点到晚上7点之间
- 晚于晚上7点
我发现很难判断当前时间是否在某个时间段内:
if(currentHour < 7){
console.log("Time is before than 7 am :" + 0 );
}
else if (currentHour > 19){
console.log("Time is after than 7 pm :" + 12148 );
}
else if(//Compare between the hours)
请提供适当的代码。