If you only have to compare the days, all you have to do is checking if one value is equal to, or higher than the other.
You can accomplish this by getting both values, take the last part, and compare those. For example:
var date = '2016-04-08';
var day = date.split('-')[2];
split
turns the string into an array: MDN
The last value is the day. If you want to compare it as a number, make sure to turn it into a number (or int
): MDN
DEMO
If you want to compare the whole date, which makes more sense IMO, it's a bit more tricky. In that case you have to turn the values into proper JS Date
objects. Once they are both Date
objects, you can compare them.
For this you can also use the split
part as above. Provide the three parts (year, month, day) to the Date
object to create a valid date object.
DEMO