new Date().getTime()
var timeDate = "2019-05-09 14:50:48"; new Date(timeDate).getTime()
時間轉換 --格式1時1分11秒code
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:11get
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 })