时间戳与时区
最后更新于
/**
* 把指定时区的时间换算到当地时区
* @param {number} timestamp 指定的时间戳
* @param {number} timeZone 指定时间戳的时区,
* @returns {number} 系统时区的时间
*/
function transformToLocalTime(timestamp, timeZone = -8) {
const date = new Date();
const zone = date.getTimezoneOffset() / 60;
const zoneGap = zone - timeZone;
timestamp += (zoneGap * 60 * 60 * 1000);
return timestamp;
}