It's quite simple:
if(new Date(fit_start_time) <= new Date(fit_end_time))
{//compare end <=, not >=
//your code here
}
Comparing 2 Date
instances will work just fine. It'll just call valueOf
implicitly, coercing the Date
instances to integers, which can be compared using all comparison operators. Well, to be 100% accurate: the Date
instances will be coerced to the Number
type, since JS doesn't know of integers or floats, they're all signed 64bit IEEE 754 double precision floating point numbers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…