js 时间格式化
作者:互联网
话不多说 直接上代码
changeTime(){ let nowTime = new Date() let year = nowTime.getFullYear() let month = nowTime.getMonth()+1 if((month+'').length==1){ month = '0'+month } let day = nowTime.getDate() let hours = nowTime.getHours() if((hours+'').length==1){ hours = '0'+hours } let min = nowTime.getMinutes() if((min+'').length==1){ min = '0'+min } let sec = nowTime.getSeconds() return `${year}-${month}-${day} ${hours}:${min}:${sec}` },
标签:格式化,min,nowTime,month,hours,length,时间,let,js 来源: https://www.cnblogs.com/CIBud/p/15076339.html