我正在寻找一种将一个时区的日期转换为另一个时区的函数。
它需要两个参数,
是否有捷径可寻?
var aestTime = new Date().toLocaleString(“en-US”, {timeZone: “Australia/Brisbane”});
aestTime = new Date(aestTime); console.log('AEST time: '+aestTime.toLocaleString()) var asiaTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Shanghai"}); asiaTime = new Date(asiaTime); console.log('Asia time: '+asiaTime.toLocaleString()) var usaTime = new Date().toLocaleString("en-US", {timeZone: "America/New_York"}); usaTime = new Date(usaTime); console.log('USA time: '+usaTime.toLocaleString()) var indiaTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"}); indiaTime = new Date(indiaTime); console.log('India time: '+indiaTime.toLocaleString())