js:日期处理(处理成2012-2-28 3:28)
作者:
轩轩小王子 | 来源:发表于
2019-02-16 19:28 被阅读0次
1.Q:日期处理
A:
timingTransmissionFormat(date){
if(!date){
return ""
}
console.log('date',date) //date 1548345600000
let finalFormatY = new Date(date).getFullYear();
let finalFormatM = new Date(date).getMonth() + 1 < 10 ? '0' + (new Date(date).getMonth() + 1) : new Date(date).getMonth() + 1;
let finalFormatD = new Date(date).getDate() < 10 ? '0' + (new Date(date).getDate()) : new Date(date).getDate();
let finalFormatH = new Date(date).getHours() <10 ? '0' + (new Date(date).getHours()):new Date(date).getHours();
let finalFormatMi = new Date(date).getMinutes()<10 ? '0' + (new Date(date).getMinutes()):new Date(date).getMinutes();
return finalFormatY + '-' + finalFormatM + '-' + finalFormatD + ' ' + finalFormatH + ':' + finalFormatMi
}
本文标题:js:日期处理(处理成2012-2-28 3:28)
本文链接:https://www.haomeiwen.com/subject/smuieqtx.html
网友评论