js比较两个时分秒的大小

// 如果time2大于time1 返回true 否则 返回false
  function compareTime(time1,time2) {
      if(time_to_sec(time2)-time_to_sec(time1)>0){ 
          return true;
      }
      return false;
  }

//将时分秒转为时间戳
  function time_to_sec(time) {
      if (time !== null) {
          var s = "";
          var hour = time.split(":")[0];
          var min = time.split(":")[1];
          var sec = time.split(":")[2];
          s = Number(hour * 3600) + Number(min * 60) + Number(sec);
          return s;
      }
  }
原文地址:https://www.cnblogs.com/wangshengli520/p/14986385.html