Im wondering if anyone can point me to some documentation on how to solve my issue.
Still new at native JS, and looking to do some date calculations.
Basically I need to calculate the duration between X and Y dates from and HTML forms input type date.
I have a rough sketch of my HTML and JS..
but still I cannot solve the issue without propper guidance and documentation.
<div>
<form>
<label for="start-date"></label>
<input type="date" id="start-date">
<label for="end-date"></label>
<input type="date" id="end-date">
<label for="duration"></label>
<input type="text" id="duration">
</form>
</div>
const startDate = document.getElementById("start-date").value
const endDate = document.getElementById("end-date").value
let duration_from_form = document.getElementById("duration").value
let duration = endDate - startDate;
if (duration_from_form === ""){
duration_from_form = duration;
}
}
I know both of them a rough mockups and not ideal, but I’d love some help finding propper documentation on this matter.
Kind regards