How big is the time?

simple time comparison
time1 = 15:30:26
time2 = 17:00:00
how to compare these two times, ask the boss for advice

Jul.14,2022

you can use moment.js

moment('2016-05-04').isBefore('2016-05-16')

isn't it easy to calculate if it's just minutes and seconds? Just turn it all into seconds and compare the size.
it is more convenient to use moment or dayjs if you are the one with a date. Convert it to Date, and then Date.getTime () for comparison.


makeDurationToSeconds (time) {

  let str = time
  let arr = str.split(':')
  let hs = parseInt(arr[0] * 3600)
  let ms = parseInt(arr[1] * 60)
  let ss = parseInt(arr[2])
  let seconds = hs + ms + ss
  return seconds
},

returns a comparison in seconds, and I compare it in a second.


Direct comparison is fine

Menu