Given a start
and an end
date, I would like to know the percentage that has been achieved from the start
date to the current date relatively to the end date.
In other words: with a given date, I would want to know in percent how far I am still to the end date.
But if I try that as shown in the code, I get a utopian number (-97%).
const isToday = (durchlauf) => {
var start = new Date(2020, 12, 1);
var end = new Date(2021, 1, 1);
const today = new Date();
var total = end - start;
var progress = today - start;
console.log(Math.round((progress / total) * 100) + "%");
//OUTPUT
-97%
};
Returns a value of -97%, why?