小程序自定义格式化时间函数

小程序自定义格式化时间戳函数


formatTime (time) {
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
let date = new Date(time);
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
return [year, month, day].map(formatNumber).join('.')
}

猜你喜欢

转载自blog.csdn.net/liukai6/article/details/80844171
今日推荐