Answers for "Get specific timezone time"

0

Get specific timezone time

function calcTime(city, offset) {

    d = new Date();

    utc = d.getTime() + (d.getTimezoneOffset() * 60000);

    nd = new Date(utc + (3600000*offset));

    return "The local time in " + city + " is " + nd.toLocaleString();

}

// get Bombay time
console.log(calcTime('Bombay', '+5.5'));

// get Singapore time
console.log(calcTime('Singapore', '+8'));

// get London time
console.log(calcTime('London', '+1'));
Posted by: Guest on February-16-2022

Code answers related to "Get specific timezone time"

Browse Popular Code Answers by Language