I'm trying to determine whether to show a tag of an upcoming birthday or not by this boolean logic that I'm a bit lost at.
const birthDayDate = new Date('1997-09-20');
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);
const threshold = new Date(today).setDate(today.getDate() + 8);
console.log(birthDayDate >= today && birthDayDate < new Date(threshold));
This is the code piece that I have and would like it to console.log true if an upcoming birthday is within 7 days margin.
Now, given that today and as of writing this post in my timezone it is 09.14.2022, I would like it to console.log the right result which would be true, given that the date we are comparing with is in 6days not taking years into the account.