I am trying to compare two different dates to see if the date inputted is after 7 days of todays date. I have done a bit of googling and come up with this:
function val_date(input){
var date = new Date(input);
date = date.getTime() / 1000;
var timestamp = new Date().getTime() + (7 * 24 * 60 * 60 * 1000)
window.alert("Date: "+date + " = N_Date: "+timestamp);
if(timestamp > date || timestamp === date){
// The selected time is less than 7 days from now
return false;
}
else if(timestamp < date){
// The selected time is more than 7 days from now
return true;
}
else{
// -Exact- same timestamps.
return false;
}
}
I am using an alert so that I can check my progress to make sure the dates are different. The output of the alert just says:
Date: NaN = N_Date = 13255772630 (<- or something like that).
Is there something I am doing wrong here?
Not sure if it helps but my date format is DD-MM-YYYY