2020-10-03

效果图–wx:–qiao----min----liu–

1.png

 const formatTime = date => {
   const year = date.getFullYear() //年
   const month = date.getMonth() + 1 //月
   const day = date.getDate() //日
   const hour = date.getHours() //时
   const minute = date.getMinutes() //分
   const second = date.getSeconds() //秒


   return [year].map(formatNumber) + '' + [month].map(formatNumber) + '' + [day].map(formatNumber) + '' + [hour].map(formatNumber) + [minute].map(formatNumber) + [second].map(formatNumber)
 }

 const formatNumber = n => {
   n = n.toString()
   return n[1] ? n : '0' + n
 }

 module.exports = {
   formatTime: formatTime
 }

猜你喜欢

转载自blog.csdn.net/weixin_44495982/article/details/108911432