将秒数转换为**小时**分钟

将秒数转换为:*小时**分钟

getHourMinute(val) {
    
    
      if (!val) {
    
    
        return `0小时0分钟`;
      }
      const int = parseInt(val, 10);
      const hours = parseInt(int / (60 * 60), 10);
      const leaveTime = int % (60 * 60);
      const minutes = parseInt(leaveTime / 60, 10);
      return `${
      
      hours}小时${
      
      minutes}分钟`;
    },

parseInt是取整的:

parseInt(156457, 10)
 // 156457
parseInt(156457/60, 10)
// 2607
2607*60
// 156420

猜你喜欢

转载自blog.csdn.net/weixin_43131046/article/details/125513574