javascript - World time clock with DST support and server sync -


I want to include JavaScript World Time Clock on my homepage but I do not want to change it every time a time zone Is it possible to synchronize the DST changes with the official time server so that I can present the current time for different locations live and without any change after DST? Use standard functions with

.

  $ timezones = array ("Australia / Brisbane", "America / New York", "Europe / London"); Foreign Currency ($ Tz as $ Time) {date_default_timezone_set ($ tz); The resonance is "Time at $ tz:". Date ('r'); }  

This handles all daylight savings and everything for you.

You can find a list of timezones supported here:


Edit: Javascript implementation:

  1. Use the above method to output to all the different timezones that are interested in PPP, but to get offset seconds from UTC, date ('z') Use. Use output using JSON or some so that JavaScript can be used by:

      var offsets = {'Brisbane': 36000, 'Sydney': 42000, 'London': 0} ;  
  2. Loop through all of them, essentially adding and subtracting the offset.

     for  (different cities in off-city) {var d = new date (); D.setTime (d.getTime (+) + Offset [City] * 1000); Cautious ('' in the city '+' is' + d.toUTCString ()); }  
  3. Put the above mentioned in a function called every other set using the interface.

< P> A warning though: This will not be decided, because in principle, the time zone of a place can change, when a person opens the window (they can be on the DST boundary). This is not very likely, and a page refresh will show the right time, so this is probably not a big deal.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -