格式化日期为自定义2018-01-09

 // 格式化日期
    timestampToTime (timestamp) {
      var date = new Date(timestamp) // 时间戳为10位需*1000,时间戳为13位的话不需乘1000
      const Y = date.getFullYear() + '-'
      const M =
        (date.getMonth() + 1 < 10
          ? '0' + (date.getMonth() + 1)
          : date.getMonth() + 1) + '-'
      const D = date.getDate() + ' '
      return Y + M + D
    },

猜你喜欢

转载自blog.csdn.net/jo_an_na/article/details/80915471