Make a value true if the start date is within a week from today and false after the end date

I want to display a picture in angular. There is a start date and end date. Pic should be up by start date and down by end date.

Basically, if today is the start date the pic should be up till the end date.

I have all the pieces but I can’t fit them together

const startDate = new Date('02/28/2021');
const endDate = new Date('02/29/2021');
let todaysDate = new Date();

to get the numeric values of the date you can either use

todaysDate.valueOf();

or

todaysDate.getTime()

No need to worry about the html or other part of the code. Just a boolean would do.

Something like

if(condition)
    return true; // which would mean display the pic

1 thought on “Make a value true if the start date is within a week from today and false after the end date”

Leave a Comment