zoukankan      html  css  js  c++  java
  • 天,小时,分钟的时间转换

    // 时间换算-x天x小时x分钟
    export function TimeFormat(value, hours = 8) {
        if (!value) {
            return '0天0小时0分钟';
        }
        const day = parseInt(value / 60 / hours, 10);
        const hour = parseInt((value / 60) % hours, 10);
        const min = parseInt(value % 60, 10);
        let newValue = '';
        if (day > 0) {
            newValue = `${day}天`;
        } else {
            newValue += ' 0天';
        }
        if (hour > 0) {
            newValue += `${hour}小时`;
        } else {
            newValue += '0小时';
        }
        if (min > 0) {
            newValue += `${parseFloat(min)}分钟`;
        } else {
            newValue += '0分钟';
        }
        return newValue;
    }
     
     
    // 一位小数小时
    // 时间换算-x小时
    export function TimeFormatHour(value) {
        const hour = parseFloat(value / 60, 10).toFixed(1);
        let newValue = '';
        if (hour > 0) {
            newValue += `${hour}小时`;
        }
        return newValue;
    }
  • 相关阅读:
    kubenetes-学习
    k8s-字段
    Spring Boot集成mongodb
    synchronized关键字
    Scala手记
    Python数据结构&封装解构
    Scala基础之集合
    Scala基础之集合常用方法
    Scala(2.12)之collection基本操作
    Scala基础之集合(数组)
  • 原文地址:https://www.cnblogs.com/nangras/p/13261183.html
Copyright © 2011-2022 走看看