js timestamp converted to a date when minutes and seconds format

  <Script type = "text / JavaScript">        
         var strDate = '' ; 
        $ ( function () {
             // Get timestamp 
            var nowDate = new new a Date () the getTime ();. // 1564624526889 
            // call the package a good time conversion method 
            timestampToTime (nowDate); 
        } ()) 
        
        function timestampToTime (timestamp) {
             var DATE = new new a Date (); // time stamp is required * 10 1000, the timestamp is not required by the case 13 1000 
            var the Y = DATE. the getFullYear () + '-' ;
             var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate()) + ' ';
            var h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours()) + ':';
            var m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes()) + ':';
            var s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds());
            
            strDate = Y+M+D+h+m+s;
            return strDate;
            
        }
        console.log(strDate) //2019-08-01 09:55:26
    </script>

 

Guess you like

Origin www.cnblogs.com/lyxzxp/p/11280776.html