Developer Blog

Time calculation of various Timezones

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′);

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image



Get Download Files Review Project Dashboard Know Plan And Wishlist