前端开发常用的函数总结。

1、将秒=>转为:天+小时+分钟+秒

function timeStamp(second_time) {
    var time = parseInt(second_time) + "s";
    if(parseInt(second_time) > 60) {
        var second = parseInt(second_time) % 60;
        var min = parseInt(second_time / 60);
        time = min + "min" + second + "s";
        if(min > 60) {
            min = parseInt(second_time / 60) % 60;
            var hour = parseInt(parseInt(second_time / 60) / 60);
            time = hour + "h" + min + "min" + second + "s";
            if(hour > 24) {
                hour = parseInt(parseInt(second_time / 60) / 60) % 24;
                var day = parseInt(parseInt(parseInt(second_time / 60) / 60) / 24);
                time = day + "day" + hour + "h" + min + "min" + second + "s";
            }
        }
    }
    return time;

}
posted @ 2018-05-11 10:34  前端菜鸟教程  阅读(298)  评论(0编辑  收藏  举报