gpt4 book ai didi

javascript - 在javascript中比较两次

转载 作者:行者123 更新时间:2023-11-29 14:47:55 25 4
gpt4 key购买 nike

如果当前时间为以下情况,我需要运行特定逻辑

  1. 不到早上 7 点
  2. 早上 7 点到 9 点之间
  3. 上午 9 点到晚上 7 点之间
  4. 晚上 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)

请帮助编写适当的代码。

最佳答案

if (currentHour >= 7 && currentHour <=19) {

}

关于javascript - 在javascript中比较两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30275467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com