Blame view

ceres-uniapp-master/utils/timeUtil.js 757 Bytes
3f535f30   杨鑫   '初始'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  /**
   * @FileDescription:
   * @Author: kahu
   * @Date: 2022/11/7
   * @LastEditors: kahu
   * @LastEditTime: 2022/11/7
   */
  /**
   * 时间格式化
   * @param endTimeStamp
   * @constructor
   */
  export const TimeFormatting = (timeDifference)=>{
      // 天数
      let day = Math.floor(timeDifference / 3600 / 24);
      // 小时
      let hr = Math.floor(timeDifference / 3600 % 24);
      // 分钟
      let min = Math.floor(timeDifference / 60 % 60);
      // 秒
      let sec = Math.floor(timeDifference % 60);
      return {
          day : timeFormat(day),
          hour: timeFormat(hr),
          min : timeFormat(min),
          sec : timeFormat(sec)
      }
  }
  //时分秒换算
  function timeFormat(param) { //小于10的格式化函数
      return param < 10 ? '0' + param : param;
  }