首页 > 其他分享 >js格式化时分秒以'08:08:08’的形式输出

js格式化时分秒以'08:08:08’的形式输出

时间:2022-10-13 13:56:38浏览次数:47  
标签:hour seconds 08 js time var 时分秒 minute

封装时分秒

 

function getTime() {
            var time = new Date();
            var hour = time.getHours();
            var minute = time.getMinutes();
            var seconds = time.getSeconds();
            if (hour < 10) {
                hour = '0' + hour;
            }
            if (minute < 10) {
                minute = '0' + minute;
            }
            if (seconds < 10) {
                seconds = '0' + seconds;
            }
            return '现在是' + hour + ':' + minute + ':' + seconds;

        }
        getTime();

  

标签:hour,seconds,08,js,time,var,时分秒,minute
From: https://www.cnblogs.com/doubleyancode/p/16787923.html

相关文章