時間戳、時間轉換函數


        function onet(){    
            //  得到時間戳  毫秒    
            var time=new Date().getTime()    
            //  將時間戳轉換為  Thu Dec 26 2019 11:22:22 GMT+0800 (中國標准時間)    
            var timer=new Date(time)    
            //  格式化為年月日等等格式的時間   
            function dataFormat(time){             
                return `${time.getFullYear()}-${time.getMonth() + 1 >= 10 ? (time.getMonth() + 1) : '0' + (time.getMonth() + 1)}-${time.getDate() >= 10 ? time.getDate() : '0' + time.getDate()}${time.getHours() >= 10 ? time.getHours() : '0' + time.getHours()} : ${time.getMinutes()>=10?time.getMinutes():'0'+time.getMinutes()} : ${time.getSeconds() >= 10 ? time.getSeconds() : '0' + time.getSeconds()}`;             
            }    
            dataFormat(timer)  
        }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM