タイムスタンプはYY-M-DD HH:MM:SSフォーマットに変換します.

1114 ワード

タイムスタンプはYY-M-DD HH:MM:SSフォーマットに変換します.
  formatDate (timeStamp) {
     // console.log('   ',timeStamp)
    timeStamp=`${timeStamp}000`;   //      timeStamp 10  ,         0.
    timeStamp=Number(timeStamp);
    let year = new Date(timeStamp).getFullYear();
    let month =new Date(timeStamp).getMonth() + 1 < 10? "0" + (new Date(timeStamp).getMonth() + 1): new Date(timeStamp).getMonth() + 1;
    let date =new Date(timeStamp).getDate() < 10? "0" + new Date(timeStamp).getDate(): new Date(timeStamp).getDate();
    let hh =new Date(timeStamp).getHours() < 10? "0" + new Date(timeStamp).getHours(): new Date(timeStamp).getHours();
    let mm =new Date(timeStamp).getMinutes() < 10? "0" + new Date(timeStamp).getMinutes(): new Date(timeStamp).getMinutes();
    let ss=new Date(timeStamp).getSeconds() < 10? "0" + new Date(timeStamp).getSeconds(): new Date(timeStamp).getSeconds();
    let nowTime = year + "-" + month + "-" + date +"-"+" "+hh+":"+mm +":"+ss;
     return nowTime;
  }