时间戳位数不同、时间戳转时间

1.位数不同

前端、java默认13位,安卓、ios默认10位,安卓或ios*1000就可以了

2.时间戳转时间

computed:{
  formatDate: function() {
      let date = new Date(this.todaytime*1);
      // console.log(this.todaytime);
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      let h = date.getHours();
      h = h < 10 ? "0" + h : h;
      let m = date.getMinutes();
      m = m < 10 ? "0" + m : m;
      let s = date.getSeconds();
      s = s < 10 ? "0" + s : s;
      return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
    }
}

【注意*1】

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