I've searched for a while and couldn't find anyone even touching on this subject.
I have a price of $900 slowly approach $1500 between the dates of April 1st and August 1st. That's about $5 per day, and the formula would be:
ROUND(1500 - (600 * ((DEADLINE - TODAY) / (DEADLINE - START)))
But how do I express that in terms of javascript and HTML so that I can write it out in a sentence like "Today you'll have to pay $920."
This is where I'm at so far, but I can't figure out how to zero today's date to achieve the correct calculation:
<div id="foo"></div>
<script type="text/javascript">
function getDayDiff(a, b) {
return (a - b) / 8.64e7;
}
function getPayAmount(DEADLINE, TODAY, START) {
return Math.round(1500 - (600 * getDayDiff(DEADLINE, TODAY) / getDayDiff(DEADLINE, START)));
}
document.getElementById("foo").innerHTML = "Today you'll have to pay $" + getPayAmount(new Date(2021, 08, 1), new Date(), new Date(2021, 4, 1));
</script>