js 时间戳转化为时间

           // 时间戳转为时间
        bb="xxxx";//时间戳
            var date = new Date(bb);
            Y = date.getFullYear() + '-';
            M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) :         date.getMonth()+1) + '-';
            D = date.getDate() + ' ';
            h = (date.getHours()  < 10 ? '0' + (date.getHours()) : date.getHours())+':';
            m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes())+':';
            s = (date.getSeconds()  < 10 ? '0' + (date.getSeconds()) : date.getSeconds()); 
            var getdatetime = (Y+M+D+h+m+s);                         

猜你喜欢

转载自www.cnblogs.com/Ananiah/p/10809664.html