Sunday, March 6, 2011

Javascript World Timezone Difference to GMT Calculator

Dear everyone

I was hoping someone could send me in the direction of a regularily updating time zone database.

I have found one, but apologies i cant remember where it was from, however with the current GMT clock change fast approaching, i fear all my data will be incorrect, ie the differences from UK to New Yrok will change from 5 hours behind to 6 hours behind.

Any help on this matter would be much appreciated.

Cameron

From stackoverflow
  • Do you mean like the Olson database ?

    For instance, the fleegix.js javascript library is a timezone-enabled, drop-in replacement for the stock JavaScript Date, giving you full-blown timezone support, independent from the timezone set on the end-user's machine running the browser. It uses the Olson zoneinfo files for its timezone data.

    I believe the time-converter uses also such a database, as well as timeanddate.com, e.g. for London or New-York.


    Any DST information (Daylight Saving times) can be deduced from timeanddate.com, but also from daylight-savings-time.info

    Here is a javascript program that does exploit DST informations in order to apply the correct time shift.
    And also another script for SimpleTimeZone.

    You can also query DST data from global-time-zones.com, as in wwp.britishsummertime.co.uk. You have also informations in webexhibits.org

    See this forum for a lengthy discussion about how to retrieve DST informations.

    Finally, see that SO question for a tar.gz Olson database example.

  • Thank you for the speedy response, basically I am after list of about 50 cities each with their difference to GMT.

    I have had a nose at the Olson database and I cant find differenes to GMT

    // Add Items to Combo Box.
    locations.addItem({data:+0, label:"Abidjan, Ivory Coast"});
    locations.addItem({data:+4, label:"Abu Dhabi, UAE"});
    locations.addItem({data:+1, label:"Abuja, Nigeria"});
    locations.addItem({data:+3, label:"Addis Ababa,  Ethiopia"});
    locations.addItem({data:+10, label:"Adelaide, Australia"});
    locations.addItem({data:+3, label:"Aden,  South Yemen"});
    locations.addItem({data:-9, label:"Alaska, USA"});
    locations.addItem({data:+0, label:"Algiers, Algeria"});
    locations.addItem({data:+1, label:"Amsterdam, Netherlands"});
    locations.addItem({data:+12, label:"Anadyr,  Russia"});
    locations.addItem({data:+3, label:"Antananarivo,  Madagascar"});
    locations.addItem({data:-3, label:"Asuncion, Paraguay"});
    locations.addItem({data:+2, label:"Athens, Greece"});
    locations.addItem({data:-5, label:"Atlanta, USA"});
    locations.addItem({data:+3, label:"Baghdad, Iraq"});
    locations.addItem({data:+0, label:"Bamako, Mali"});
    locations.addItem({data:+8, label:"Bandar Seri Begawan, Brunei"});
    locations.addItem({data:+7, label:"Bangkok, Thailand"});
    locations.addItem({data:+1, label:"Bangui, Central African Republic"});
    

    This is the type of thing I have all ready, however I fear it will be incorrect when the clocks change next week, in the UK

    VonC : I just completed my answer with DST informations and links. Tell me if that helps you.
  • If you have the latitude and longitude of wherever it is you want the timezone information for then you can map that to live timezone info using a service such as this one: http://www.earthtools.org/webservices.htm#timezone

    If you are starting with an address or place name, you can get the lat/lng information using a geocoding service - e.g. see geonames.org, or google and yahoo also have services. Then use the timezone service as above.

  • fleegix is naive and buggy

0 comments:

Post a Comment