I'm doing an app, and I encounter this problem, I thought comparing dates will be that easy but it's not. My condition inside if
works well if the dates are of the same year, but if the value is like the value given below, it doesn't the result becomes true
which should be false
. So how do I properly compare this date format I have?
startDate.toLocaleDateString() has a value of 12/24/2016
endDate.toLocaleDateString() has a value of 01/03/2017
if(startDate.toLocaleDateString() > endDate.toLocaleDateString())
{
//do this
}
else
{
//do this
}