时间处理由CST格式转成GMT格式时间在真机上无效,代码如下
success(res) {
// res.data 包含该记录的数据
console.log(‘首页收到的数据’, res)
var receive = res.data
console.log(‘数组的长度’,receive.length)
for (var i = 0; i <receive.length; i++) {
var creat_time =receive[i].creat_time;
console.log(‘获取到的时间’, creat_time)
var dateStr = creat_time.split(" ");
var strGMT = dateStr[0] + " " + dateStr[1] + " " + dateStr[2] + " " + dateStr[5] + " " + dateStr[3] + " GMT+0800";
var creat_time = new Date(Date.parse(strGMT));
console.log(‘转换后的时间’,creat_time)
var Month = creat_time.getMonth()+1
receive[i].creat_time = creat_time.getFullYear() + ‘年’ + Month + ‘月’ + creat_time.getDate()+‘日’;
console.log(‘设置的日期’, receive[i].creat_time)
}