当后端传的时间是2022-12-05T02:30:12.000+0000时,前端怎么进行格式化尼
在app.js中:
timeGl = new Date(timeGl);
let yyyy = timeGl.getFullYear();
// getMonth方法返回的是0-11之间的数字,代表1-12月份,若想和日历的月份时间对应,需要+1。
let month = (timeGl.getMonth() + 1);
if(month<10){
month = "0"+month
}
let day = (timeGl.getDate()<10)?("0"+timeGl.getDate()):(timeGl.getDate());
let hours = (timeGl.getHours()<10)?("0"+timeGl.getHours()):(timeGl.getHours());
let minutes = (timeGl.getMinutes()<10)?("0"+timeGl.getMinutes()):(timeGl.getMinutes());
let seconds = (timeGl.getSeconds()<10)?("0"+timeGl.getSeconds()):(timeGl.getSeconds());
let yyyyMMddHHmmss = yyyy + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
return yyyyMMddHHmmss;
在需要用到的页面:
listCustomerAllWinPrizeOrder: function () {
let that = this;
wx.request({
url: , //请求路径
method: 'get', //请求方式
data: {},
success: (res) => {
wx.hideLoading();
if (res.data.code == 1000) {
let list = res.data.data,
winPrizeList = list.winPrizeList;
for (var i = 0; i < winPrizeList.length; i++) {
//时间格式引用
winPrizeList[i].addTm = app.getTimeFun(winPrizeList[i].addTm)
}
} else {
//提示失败信息
app.showToastTip(res.data.msg)
}
},
fail: (res) => {
//提示失败信息
app.showToastTip('删除小程序重试')
}
});
},