1function calcTime(city, offset) {
2 // create Date object for current location
3 var d = new Date();
4
5 // convert to msec
6 // subtract local time zone offset
7 // get UTC time in msec
8 var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
9
10 // create new Date object for different city
11 // using supplied offset
12 var nd = new Date(utc + (3600000*offset));
13
14 // return time as a string
15 return "The local time for city"+ city +" is "+ nd.toLocaleString();
16}
17
18alert(calcTime('Bombay', '+5.5'));
19