📌  相关文章
📜  获取特定时区的日期 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:24.012000             🧑  作者: Mango

代码示例1
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()