Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
101
rated 0 times [  104] [ 3]  / answers: 1 / hits: 144504  / 8 Years ago, fri, may 27, 2016, 12:00:00

I'm currently trying to see if the date value is set to today's date or greater.



var date = document.getElementById(inputDate).value;
var varDate = new Date(date); //dd-mm-YYYY
var today = new Date();

if(varDate >= today) {
//Do something..
alert(Working!);
}


Date format dd-mm-YYYY



The current code above won't work.


More From » javascript

 Answers
9

If you only want to compare Date and not Date-Time then add this line



var today = new Date();
today.setHours(0,0,0,0);


before comparison.


[#61997] Thursday, May 26, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byron

Total Points: 616
Total Questions: 101
Total Answers: 91

Location: Reunion
Member since Wed, Apr 14, 2021
3 Years ago
;