How to check if input date is equal to today date in JavaScript

1 Answer

0 votes
const inputDate = new Date("5/6/2022"); // m/d/yyyy

const todaysDate = new Date();

if (inputDate.setHours(0,0,0,0) == todaysDate.setHours(0,0,0,0)) {
    console.log("equal");
} else {
		console.log("not equal");
}
  
  
  
  
  
/*
run:
  
"equal"
  
*/

 



answered May 6, 2022 by avibootz

Related questions

1 answer 159 views
1 answer 172 views
1 answer 151 views
1 answer 201 views
1 answer 216 views
1 answer 165 views
1 answer 182 views
...