let data = getMyDate(createTime); //(createTime /接口获取到的时间戳) function getMyDate(str){ let oDate = new Date(str), oYear = oDate.getFullYear(), oMonth = oDate.getMonth()+1, oDay = oDate.getDate(), // oHour = oDate.getHours(), 时 // oMin = oDate.getMinutes(), 分 // oSen = oDate.getSeconds(), 秒 oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay); return oTime; } function getzf(num){ if(parseInt(num) < 10){ num = '0'+num; } return num; }