js 格林威治时间转正常格式并兼容ios

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;
        };

调用

var time = ‘2019-01-10T08:43:00.000+0000‘;
console.log(‘time‘,timeChange(time));

js 格林威治时间转正常格式并兼容ios

上一篇:C++内存未释放的情况


下一篇:ios中输入法把 内容顶起后 内容下不来问题