Consider I have a date, for example 01 march 2021 and the today date.
What I would like to obtain is a new date that is the nearest to today and is 01 march 2021 + n * (14 days)
with n a positive number.
Example:
if today is 20 may 2021 ---> 10 may 2021 (so n in that case is 5)
if today is 24 may 2021 ---> 24 may 2021 (n = 6)
if today is 25 may 2021 ---> 24 may 2021 (n = 6)
How can I do that?
I would like to create a function similar to:
function getDateFrom(startDate, stepInDays) {
return date
}
const startDate = new Date(2021, 2, 1) // 01 march 2021
const d = getDateFrom(startDate, 14)
I'm missing the logic behind that