问题已解决
打卡两次,中午休息1个小时,用函数怎么计算?
温馨提示:如果以上题目与您遇到的情况不符,可直接提问,随时问随时答
速问速答你可以使用以下函数来计算:
函数1:
function calculateHours(startTime, endTime, breakTime) {
let totalHours = 0;
let startTimeHour = startTime.getHours();
let endTimeHour = endTime.getHours();
let breakTimeHour = breakTime.getHours();
totalHours = endTimeHour - startTimeHour - breakTimeHour;
return totalHours;
}
函数2:
function calculateHours(startTime, endTime, breakTime) {
let totalHours = 0;
let startTimeMinutes = startTime.getMinutes();
let endTimeMinutes = endTime.getMinutes();
let breakTimeMinutes = breakTime.getMinutes();
totalHours = (endTimeMinutes - startTimeMinutes - breakTimeMinutes) / 60;
return totalHours;
}
2023 02/06 19:14