varformat=function(time, format){var t =newDate(time);vartf=function(i){return(i <10?'0':'')+ i};return format.replace(/yyyy|MM|dd|HH|mm|ss/g,function(a){switch(a){case'yyyy':returntf(t.getFullYear());break;case'MM':returntf(t.getMonth()+1);break;case'mm':returntf(t.getMinutes());break;case'dd':returntf(t.getDate());break;case'HH':returntf(t.getHours());break;case'ss':returntf(t.getSeconds());break;}})}--------------------var time =format(time,"yyyy-MM-dd HH:mm:ss");
将后端传过来的时间戳在前段转换为时间有两种方法:1,new Date()方法$("#time-info").text(new Date(this.list[this.inum].markTime).FormatNew("yyyy-MM-dd hh:mm"))2,转化函数方法var format = function(time, format){ var t = new Date(time); var tf = function(i){return (i < 10 ? '0'