老版本Safari 格林威治时间
1. 采坑说明
在比较老的ipad中,使用new Date(2021-03-04T16:00:00.000+0000) 格式化格林威治时间失败,最后的日期会变成当日的
2. 解决办法
function timeChange(time) {
var date = time.substr(0, 10); //年月日
var hours = time.substring(11, 13);
var minutes = time.substring(14, 16);
var seconds = time.substring(17, 19);
var timeFlag = date + ' ' + hours + ':' + minutes + ':' + seconds;
timeFlag = timeFlag.replace(/-/g, "/");
timeFlag = new Date(timeFlag);
timeFlag = new Date(timeFlag.getTime() + 8 * 3600 * 1000);
timeFlag = timeFlag.getFullYear() + '-' + ((timeFlag.getMonth() + 1) < 10 ? "0" + (timeFlag.getMonth() + 1) : (timeFlag.getMonth() + 1)) + '-' + (timeFlag.getDate() < 10 ? "0" + timeFlag.getDate() : timeFlag.getDate()) + ' ' + timeFlag.getHours() + ':' + timeFlag.getMinutes() + ':' + (timeFlag.getSeconds() < 10 ? "0" + timeFlag.getSeconds() : timeFlag.getSeconds());
return timeFlag;
};