Say we have 2 Date objects in Javascript;
var d1 = new Date('...');
var d2 = new Date('...');
We do a comparison:
d1 < d2;
This comparison will always take into account hours, minutes, seconds.
I want it to only take into account the year, month and date for comparison.
What’s the easiest way to do this?
jQuery is allowed aswell.
Reset the
hours,minutes,seconds, andmilliseconds:Or using
setHours, which is less verbose:And finally, to compare if the resulting
Dates are the same usegetTime():