function calcTime(city, offset) { // create Date object for current location d = new Date(); // convert to msec // add local time zone offset // get UTC time in msec utc = d.getTime() + (d.getTimezoneOffset() * 60000); // create new Date object for different city // using supplied offset nd = new Date(utc + (3600000*offset)); // return time as a string return "The local time in " + city + " is " + nd.toLocaleString(); } // alert(calcTime('Bangkok', '+7')); // get Singapore time alert(calcTime('Singapore', '+8')); // get London time alert(calcTime('London', '+1'));