I need to check if the date is in the past using javascript.
The date format is like this: 10/06/2018
I can do this using the following code:
var datep = '10/06/2018';
if(Date.parse(datep)-Date.parse(new Date()) < 0) {
alert('date is in the past');
}
But this code seems to only check for Year
. So if the Month
or the Day
is in the past, it will ignore that!
Could someone please advice on how to check for the day and month as well as the year
?
Thanks in advance.
EDIT:
The date format is
dd/mm/yyyy