时间格式化 将毫秒值转变成 年月日 时分秒

传入毫秒值(datestemp)

// 将毫秒值 转变成 yyyy-MM-dd 
    formatTime(datestemp){
      const date = new Date(datestemp)
      const toDouble = (n) => (n+'').length < 2 ? '0' + n : n
      const endDay = [date.getFullYear(), toDouble(date.getMonth() + 1), toDouble(date.getDate())].join('-')
      const clock = date.toTimeString().slice(0,8)
      return endDay+' '+clock
    },

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