📅  最后修改于: 2022-03-11 15:02:24.012000             🧑  作者: Mango
function getTimeFromTimezone(offset) {
const currentDate = new Date() //get current time to calculate the UTC time
let utc = currentDate.getTime() + (currentDate.getTimezoneOffset() * 60000) //calculates the UTC time
let nd = new Date(utc + (3600000*offset)) // get the current timezone with the offset
return nd
}
getTimeFromTimezone('+5.5').toLocaleString()
getTimeFromTimezone('-3').toLocaleString()