js时间戳转换日期,时间转换

//处理时间戳
    dealTime(e){
      if(!e)return'';
      let dd = e+'';
      let date;
      if(dd.length == 10){
        let timestamp = Number(dd)
        date = new Date(parseInt(timestamp) * 1000);
      }else{
        let timestamp = Number(dd)
        date = new Date(parseInt(timestamp));
      }
      let Year = date.getFullYear();
      let Moth = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
      let Day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
      let Hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
      let Minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
      let Sechond = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
      let  GMT =  Year + '-' + Moth + '-' + Day + '   '+ Hour +':'+ Minute  + ':' + Sechond;
      return GMT
    },

你可能感兴趣的:(javascript,前端)