Hours Worked Calculator

.h-worked-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #e1e4e8; border-radius: 12px; background-color: #ffffff; box-shadow: 0 4px 6px rgba(0,0,0,0.05); color: #333; } .h-worked-header { text-align: center; margin-bottom: 30px; } .h-worked-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; } @media (max-width: 600px) { .h-worked-grid { grid-template-columns: 1fr; } } .h-worked-input-group { display: flex; flex-direction: column; } .h-worked-label { font-weight: 600; margin-bottom: 8px; font-size: 14px; color: #4a5568; } .h-worked-input { padding: 12px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 16px; transition: border-color 0.2s; } .h-worked-input:focus { outline: none; border-color: #4299e1; box-shadow: 0 0 0 3px rgba(66,153,225,0.1); } .h-worked-btn { width: 100%; padding: 15px; background-color: #2b6cb0; color: white; border: none; border-radius: 6px; font-size: 18px; font-weight: 700; cursor: pointer; transition: background-color 0.2s; } .h-worked-btn:hover { background-color: #2c5282; } .h-worked-result { margin-top: 25px; padding: 20px; background-color: #f7fafc; border-radius: 8px; display: none; } .h-worked-result-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; color: #2d3748; border-bottom: 2px solid #edf2f7; padding-bottom: 10px; } .h-worked-val { font-size: 24px; font-weight: 800; color: #2b6cb0; } .h-worked-content { margin-top: 40px; line-height: 1.6; color: #4a5568; } .h-worked-content h2 { color: #2d3748; margin-top: 30px; } .h-worked-content h3 { color: #4a5568; margin-top: 20px; } .h-worked-example { background: #edf2f7; padding: 15px; border-left: 4px solid #2b6cb0; margin: 15px 0; }

Hours Worked Calculator

Calculate total shift time, decimal hours, and earnings with ease.

Work Summary

How to Calculate Hours Worked

Tracking your work hours accurately is essential for both employees and freelancers to ensure fair compensation and productivity management. This Hours Worked Calculator simplifies the process of subtracting breaks and handling shifts that cross over midnight.

The Basic Formula

To calculate your work duration manually, use the following steps:

  1. Determine the Total Elapsed Time: Subtract the start time from the end time.
  2. Subtract Breaks: Deduct any unpaid lunch or rest periods from the total elapsed time.
  3. Convert to Decimal: Since most payroll systems use decimal hours (e.g., 7.5 hours instead of 7 hours and 30 minutes), divide the remaining minutes by 60 and add them to the total hours.
Example Calculation:
Start Time: 8:30 AM | End Time: 5:15 PM | Break: 45 minutes

1. Elapsed Time: 8 hours and 45 minutes.
2. Minus Break: 8 hours and 0 minutes.
3. Decimal Format: 8.00 hours.

Handling Night Shifts

If your shift starts in the evening (e.g., 10:00 PM) and ends the next morning (e.g., 6:00 AM), our calculator automatically detects the day change. Mathematically, you add 24 hours to the end time if it is numerically "smaller" than the start time to get the correct duration.

Converting Minutes to Decimals

For your records, here is a quick conversion guide for common minute intervals:

  • 15 minutes = 0.25 hours
  • 30 minutes = 0.50 hours
  • 45 minutes = 0.75 hours
function calculateHoursWorked() { var startTime = document.getElementById('startTime').value; var endTime = document.getElementById('endTime').value; var breakMin = parseFloat(document.getElementById('breakMinutes').value) || 0; var hourlyRate = parseFloat(document.getElementById('hourlyRate').value) || 0; if (!startTime || !endTime) { alert("Please enter both start and end times."); return; } var startParts = startTime.split(':'); var endParts = endTime.split(':'); var startTotalMinutes = (parseInt(startParts[0]) * 60) + parseInt(startParts[1]); var endTotalMinutes = (parseInt(endParts[0]) * 60) + parseInt(endParts[1]); // Handle overnight shifts if (endTotalMinutes < startTotalMinutes) { endTotalMinutes += 24 * 60; } var totalWorkMinutes = endTotalMinutes – startTotalMinutes – breakMin; if (totalWorkMinutes < 0) { alert("Break duration cannot exceed total shift time."); return; } var hours = Math.floor(totalWorkMinutes / 60); var minutes = totalWorkMinutes % 60; var decimalHours = totalWorkMinutes / 60; var resultArea = document.getElementById('resultArea'); var displayTotalTime = document.getElementById('displayTotalTime'); var displayDecimal = document.getElementById('displayDecimal'); var displayPay = document.getElementById('displayPay'); resultArea.style.display = 'block'; displayTotalTime.innerHTML = "Total Time: " + hours + "h " + minutes + "m"; displayDecimal.innerHTML = "Decimal Hours: " + decimalHours.toFixed(2) + " hours"; if (hourlyRate > 0) { var totalPay = decimalHours * hourlyRate; displayPay.innerHTML = "Estimated Pay: $" + totalPay.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); } else { displayPay.innerHTML = ""; } }

Leave a Comment