simple time comparison
time1 = 15:30:26
time2 = 17:00:00
how to compare these two times, ask the boss for advice
simple time comparison
time1 = 15:30:26
time2 = 17:00:00
how to compare these two times, ask the boss for advice
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
Previous: Please tell me how js finds strings contained in certain characters through regularization.
Next: How does Python catch an exception and continue to run?
my way is to use toLocaleDateString (), to get the string form of time 1 2018,). Gettime () 4 and 28, and then bring it into new date (2018-4-28 then string 2 also gets the time, of the date then subtract the time of the date of string 2 from the ti...
the first two arrays are like this. The b array adds a field to the an array a = [{ label: , organizeId: 1001 }, { label: , organizeId: 1002 }, { label: , organizeId: 1003 }, { label: , ...
export function postMethod(data) { const baseURL = process.env.BASE_API axios({ method: post , url: baseURL + img_upload , timeout: 50000, data: data, headers: { loginToken : getLoginToken() } }).then(res =&g...
whether I abbreviate it or write it step by step, it is an error. There is no corresponding array filtered out. Item.username is a string and can be printed out, not without value. Why the report was wrong. Please point out if there is anything wron...
the demo code is as follows: test async< button> < div> <script> new Vue({ el: -sharpapp , methods: { setTimeout getFoo() { return new ...