Timestamp conversion event format

// Determine whether to add 0 to the front 
    add0 (m) {
       return m < 10 ? '0' + m : m
    },
    // Time conversion 
    timeFormat (timestamp) {
     // timestamp is an integer, otherwise parseInt is required to convert, there will be no less 0 
      var time = new Date(timestamp)
       // var year = time.getFullYear() 
      // var month = time.getMonth() + 1 
      // var date = time.getDate() 
      var hours = time.getHours()
       var minutes = time.getMinutes()
       var seconds = time.getSeconds()
       // return year + '-' + this.add0(month) + '-' + this.add0(date) + ' ' + this.add0(hours) + ':' + this.add0(minutes) + ':' + this.add0(seconds) 
      return  this.add0(hours) + ':' + this.add0(minutes) + ':' + this.add0(seconds)
    },

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324650552&siteId=291194637