时间戳、时间转换函数


        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