उदाहरण
toLocaleString() में timeZone ऑप्शन का उपयोग करके अलग-अलग टाइमज़ोन का समय प्राप्त करें।
var todayDateTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"});
todayDateTime = new Date(todayDateTime);
console.log("The Asia Date time is=");
console.log(todayDateTime);
var americaDateTime = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
americaDateTime = new Date(americaDateTime);
console.log("The America Date time is=");
console.log(americaDateTime);
प्रोग्राम चलाने के लिए:
node fileName.js
आउटपुट
PS C:\Users\Amit\javascript-code> node demo193.js The Asia Date time is= 2020-08-08T08:44:50.000Z The America Date time is= 2020-08-07T23:14:50.000Z