Time Calculator : users can input two time values using time input fields. Users can perform arithmetic operations (addition, subtraction, multiplication, division) on the time values by clicking the respective buttons. The result is displayed below the buttons.
function subtractTimes() { const time1 = getTimeInSeconds(document.getElementById('time1').value); const time2 = getTimeInSeconds(document.getElementById('time2').value); displayResult(time1 - time2); }
function multiplyTime() { const time1 = getTimeInSeconds(document.getElementById('time1').value); const time2 = getTimeInSeconds(document.getElementById('time2').value); displayResult(time1 * time2); }
function divideTime() { const time1 = getTimeInSeconds(document.getElementById('time1').value); const time2 = getTimeInSeconds(document.getElementById('time2').value); displayResult(time1 / time2); }
function getTimeInSeconds(timeString) { const [hours, minutes] = timeString.split(':').map(Number); return hours * 3600 + minutes * 60; }
function displayResult(resultInSeconds) { const hours = Math.floor(resultInSeconds / 3600); const minutes = Math.floor((resultInSeconds % 3600) / 60); const seconds = resultInSeconds % 60; document.getElementById('result').innerText = `${hours} hours ${minutes} minutes ${seconds} seconds`; }
NathTech Guid, Introduction to Toncoin (TON) Toncoin (TON) is the native cryptocurrency of The…
NathTech Guide , Introduction: glowing skin is a reflection of overall health and self-care. While…
NathTech Guid Introduction: Achieving glowing skin is a goal that many people aspire to, but…
Nathtech Guideline , Introduction Maintaining fitness is crucial for a healthy and fulfilling life, regardless…
Nathtech Guideline , Introduction ; In today's fast-paced world, maintaining fitness is more than…
Nathtech's Guideline , Introduction , In a world that is increasingly focused on…