打卡两次,中午休息1个小时,用函数怎么计算?
问题已解决
所属话题:
#实务#
84785040 | 提问时间:2023 02/06 19:03
你可以使用以下函数来计算:
函数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
相关问答
查看更多最新问答
查看更多