滞留时间计算

  // 滞留时间  a是当前时间, b是上一个时间
  const diffProcessDuration = (a, b) => {
    const time1 = dayjs(a);
    const time2 = dayjs(b);
    const diffInSeconds = time1.diff(time2, 'second');
    const days = Math.floor(diffInSeconds / 86400);
    const hours = Math.floor((diffInSeconds % 86400) / 3600);
    const minutes = Math.floor((diffInSeconds % 3600) / 60);
    const seconds = diffInSeconds % 60;
    const result = `${days > 0 ? `${days}天` : ''}${hours > 0 ? `${hours}时` : ''}${minutes > 0 ? `${minutes}分` : ''}${seconds}秒`;
    return result;
  };

 

posted @ 2025-05-19 15:14  行走的蒲公英  阅读(46)  评论(0)    收藏  举报