當(dāng)前位置:財(cái)稅問題 >
實(shí)務(wù)
問題已解決
打卡兩次,中午休息1個(gè)小時(shí),用函數(shù)怎么計(jì)算?
溫馨提示:如果以上題目與您遇到的情況不符,可直接提問,隨時(shí)問隨時(shí)答
速問速答你可以使用以下函數(shù)來計(jì)算:
函數(shù)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;
}
函數(shù)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
閱讀 509