get time in specific timezone javascript code example
Example 1: how to see my timezone using js
document.getElementById("time").innerHTML = Date().slice(Date().indexOf("(")+1,Date().lastIndexOf(")"));
Example 2: get user time using timezone javascript
function calcTime(city, offset) {
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
var nd = new Date(utc + (3600000*offset));
return "The local time for city"+ city +" is "+ nd.toLocaleString();
}
alert(calcTime('Bombay', '+5.5'));