本人微信公众号"aeolian"~

秒转为时分秒格式js

秒转为时分秒格式

function formatSeconds(value) {
            if(value == undefined)
            {
                value = 0;
            }    
            var second = parseInt(value);//
            var min = 0;//
            var hour = 0;// 小时
            if(second > 60) {
                min = parseInt(second/60);
                second = parseInt(second%60);
                if(min > 60) {
                    hour = parseInt(min/60);
                    min = parseInt(min%60);
                    }
                }
            var result = ""+parseInt(second)+"秒";
            if(min > 0) {
                result = ""+parseInt(min)+"分"+result;
            }
            if(hour > 0) {
                result = ""+parseInt(hour)+"小时"+result;
            }
            return result;
        } 

《秒转为时分秒格式js》

 

点赞

Leave a Reply

Your email address will not be published. Required fields are marked *