js判断时间段

time:00:00:01-01:00:00

function compareSetHours(time) {
  var result = false
  var times = time.split('-')
  if (times.length === 2) {
    var date = new Date()
    var time1 = times[0].split(':')
    var time2 = times[1].split(':')
    result = date.setHours(time1[0], time1[1], time1[2]) < date.setHours(time2[0], time2[1], time2[2])
  }
  return result
}

  

posted @ 2020-11-04 11:52  石shi  阅读(599)  评论(0编辑  收藏  举报