js 时间戳转换成hh:mm:dd:hh:mm:ss

2018-07-03  本文已影响0人  Symbian米汤
//时间戳日期转换
        function getTime(time){
            console.log(time);
            var times ='';
            var date = new Date(time);
            Y = date.getFullYear() + '-';
            M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            D = date.getDate() + ' ';
            h = date.getHours() + ':';
            m = date.getMinutes() + ':';
            s = date.getSeconds();
            console.log(Y+M+D+h+m+s);
            times=Y+M+D+h+m+s;
            return times;
        }


上一篇 下一篇

猜你喜欢

热点阅读