判断早中晚的时间

  

  var that = this;

  /*小程序判断时间段的函数*/
  var time = parseInt(new Date().getHours()); //返回小时数
  if (7 < time && time < 11) {
    setTimeout(function () {
      console.log("这是早上")
    }, 1000)

  } else if (11 <= time && time < 17) {
    setTimeout(function () {
      console.log("这是中午")
    }, 1000)
  } else {
    setTimeout(function () {
      console.log("这是晚上")
    }, 1000)
  }
原文地址:https://www.cnblogs.com/shangjun6/p/11929906.html