Skip to content

Instantly share code, notes, and snippets.

@jagdishlove
Created September 26, 2023 05:17
Show Gist options
  • Save jagdishlove/e54c0f3d50260238a7693a4d7c888c96 to your computer and use it in GitHub Desktop.
Save jagdishlove/e54c0f3d50260238a7693a4d7c888c96 to your computer and use it in GitHub Desktop.
## adding multiple hours timedifference in javascript
function minutesToHours(minutes) {
const h = Math.floor(minutes / 60);
const m = minutes % 60;
return `${h}.${m < 10 ? "0" : ""}${m}`;
}
const totalMinutes = getTimesheetData?.reduce((sum, entry) => {
return sum + hoursToMinutes(entry.noOfHours);
}, 0);
const totalHours = minutesToHours(totalMinutes);
console.log("totalHours", totalHours);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment