function calculateGrossPay() {
var rate = document.getElementById("hourlyRate").value;
var hours = document.getElementById("hoursWorked").value;
var minutes = document.getElementById("minutesWorked").value;
var r = parseFloat(rate) || 0;
var h = parseFloat(hours) || 0;
var m = parseFloat(minutes) || 0;
if (r < 0 || h < 0 || m < 0) {
alert("Please enter positive values.");
return;
}
// Convert minutes to decimal representation
var decimalMins = m / 60;
var totalDecimalHours = h + decimalMins;
// Calculate gross pay
var totalGross = totalDecimalHours * r;
// Update UI
document.getElementById("decimalHours").innerText = totalDecimalHours.toFixed(2) + " hrs";
document.getElementById("totalPayResult").innerText = "$" + totalGross.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resultsBox").style.display = "block";
}
How to Calculate Time Worked by Hourly Rate
Understanding how to accurately calculate your earnings based on hours worked is a fundamental skill for freelancers, hourly employees, and business owners alike. While it may seem straightforward, the conversion of minutes into decimal format is where most errors occur.
The Formula for Hourly Earnings
To calculate your gross pay, you must multiply your hourly wage by the total number of hours worked. The mathematical formula is:
Gross Pay = Hourly Rate × Total Hours (in decimal form)
Converting Minutes to Decimals
Since there are 60 minutes in an hour, you cannot simply use minutes as a decimal. For example, 30 minutes is not 0.30 hours; it is 0.50 hours. To convert minutes to decimals, use this step:
Minutes ÷ 60 = Decimal Hours
If you worked 40 hours and 15 minutes, you divide 15 by 60 to get 0.25. Your total time worked is 40.25 hours.
Step-by-Step Calculation Example
Suppose you earn $22.50 per hour and you worked 38 hours and 45 minutes this week.
Convert Minutes: 45 minutes / 60 = 0.75 hours.
Total Time: 38 + 0.75 = 38.75 hours.
Calculate Pay: $22.50 × 38.75 = $871.88.
Common Conversion Chart
Here are the most common minute-to-decimal conversions used in payroll:
Minutes
Decimal Equivalent
15 Minutes
0.25
30 Minutes
0.50
45 Minutes
0.75
6 Minutes
0.10
Frequently Asked Questions
How do I calculate overtime?
Typically, overtime is calculated at 1.5 times your hourly rate for any hours worked over 40 in a single workweek. You would calculate the first 40 hours at your normal rate, then calculate the remaining hours at the "time-and-a-half" rate and add the two totals together.
Does this calculation include taxes?
No, the calculation above provides your Gross Pay, which is the amount earned before taxes, social security, and other deductions are taken out by your employer.