美文网首页
No.20190929:JS小方法

No.20190929:JS小方法

作者: 喝酸奶不舔瓶蓋 | 来源:发表于2019-09-29 13:15 被阅读0次
    1、将毫秒秒转化为xx小时xx分钟xx秒
    function MillisecondToDate(msd) {
        var time = parseFloat(msd) / 1000; //先将毫秒转化成秒
        if (null != time && "" != time) {
            if (time > 60 && time < 60 * 60) {
                time = parseInt(time / 60.0) + "分钟" + parseInt((parseFloat(time / 60.0) -
                    parseInt(time / 60.0)) * 60) + "秒";
            } else if (time >= 60 * 60 && time < 60 * 60 * 24) {
                time = parseInt(time / 3600.0) + "小时" + parseInt((parseFloat(time / 3600.0) -
                        parseInt(time / 3600.0)) * 60) + "分钟" +
                    parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
                        parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + "秒";
            } else {
                time = parseInt(time) + "秒";
            }
        }
        return time;
    }
    

    相关文章

      网友评论

          本文标题:No.20190929:JS小方法

          本文链接:https://www.haomeiwen.com/subject/gasfpctx.html