How to check if a date is today date in Node.js

1 Answer

0 votes
function isTodayDate(date) {
    const today = new Date();

    if (today.toDateString() === date.toDateString()) {
        return true;
    }

    return false;
}

console.log(isTodayDate(new Date())); 
console.log(isTodayDate(new Date('2022-03-13'))); 

  
  
  
/*
run:
        
true
false
      
*/

 



answered Mar 11, 2022 by avibootz

Related questions

1 answer 165 views
1 answer 165 views
1 answer 145 views
1 answer 151 views
1 answer 151 views
1 answer 136 views
1 answer 128 views
...