// 时间戳转化为时间
1 getDT(t) { 2 var time = new Date(t); 3 var y = time.getFullYear(); 4 var m = this.getTime(time.getMonth()+1); 5 var d = this.getTime(time.getDate()); 6 var h = this.getTime(time.getHours()); 7 var f = this.getTime(time.getMinutes()); 8 var s = this.getTime(time.getSeconds()); 9 return y+'-'+m+'-'+d+' '+h+':'+f+':'+s; 10 },
// 时间转化为时间戳
datetimeToUnix(datetime){ if(datetime=="") { return 0; } var tmp_datetime = datetime.replace(/:/g,'-'); tmp_datetime = tmp_datetime.replace(/ /g,'-'); var arr = tmp_datetime.split("-"); var now = new Date(Date.UTC(arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5])); return parseInt(now.getTime()/1000); }, getTime(n){ if(n<10){ return '0' + n; }else{ return '' + n; } }