问题详情
问题已解决
所属话题:
#实务#
打卡两次,中午休息1个小时,用函数怎么计算?
84785040 | 提问时间:2023 02/06 19:03
良老师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
下载APP,拍照搜题秒出结果

您有一张限时会员卡待领取

00:10:00

免费领取