Archive

Posts Tagged ‘timezone’

Time calculation of various Timezones

Monday, January 22nd, 2007

function calcTime(sCity, 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
sDateTime = nd.toLocaleString(); // It is total datetime format

document.write(sCity+” : “+sDateTime);

}

// Set the time for countries
calcTime(‘London’, ‘+0.0′); // ‘+0.00′ is the standard timezone of London
calcTime(‘Sydney’, ‘+10.0′);
calcTime(‘New York’, ‘-5.0′);

Recent Comments

  • Stanford Reach: Great post. Thanks!
  • Shu Crunk: I was simply browsing for useful blog articles intended for a project research and I happened to stumble...
  • Marya: Hey rather wonderful weblog!! I’ll bookmark your weblog and grab the feeds conjointly…
  • John Vay: ive just started my own hosting company its such hard work haha :P
  • write a good resume: Your the best!