时间转时间戳

  1. 当前时间转换(毫秒)
new Date().getTime()
  1. 指定时间转换(毫秒)
var timeDate = "2019-05-09 14:50:48";
new Date(timeDate).getTime()

时间戳转化为日期

时间转换 --格式1时1分11秒

dateConvert(value){
    let hour,min,sec,createDate=value
    hour=parseInt(createDate/60/60)
    min=parseInt((createDate-hour*3600)/60)
    sec=parseInt(createDate-(hour*3600+min*60))
    if(hour>0){
      if(min>0){
        if(sec>0){
          createDate=hour+'时'+min+'分'+sec+'秒'
        } else{
          createDate=hour+'时'+min+'分'
        }
      }else{
        if(sec>0){
          createDate=hour+'时'+sec+'秒'
        }else{
          createDate=hour+'时'
        }
      }
    }else if(min>0){
      createDate=sec>0?(min+'分'+sec+'秒'):(min+'分')
    }else if(sec>0){
      createDate=sec+'秒'
    }
    return createDate
  }

时间转换 --格式1:1:11

Vue.filter('TimeFilter', function(value) {
  let hour,min,sec,createDate=value
  hour=parseInt(createDate/60/60)
  min=parseInt((createDate-hour*3600)/60)
  sec=parseInt(createDate-(hour*3600+min*60))
  if(hour>0){
    if(min>0){
      if(sec>0){
        createDate=hour+':'+min+':'+sec
      } else{
        createDate=hour+':'+min+':00'
      }
    }else{
      if(sec>0){
        createDate=hour+':00'+sec
      }else{
        createDate=hour+':00:00'
      }
    }
  }else if(min>0){
    createDate=sec>0?(min+':'+sec):(min+':00')
  }else if(sec>0){
    createDate=sec+'s'
  }
  return createDate
})

沉淀
7 声望1 粉丝