javascript - Clock in different time zones -


i trying create 2 clocks on website says 2 times on it. 1 london , other new york.

i have been able create clock reads current time on computer i'm not sure how place time zone this.

the code have far is:

<script type="text/javascript" language="javascript">  function rendertime() {     var currenttime = new date();     var diem = "am";     var h = currenttime.gethours();     var m = currenttime.getminutes();     var s = currenttime.getseconds();      if (h == 0) {         h = 12     } else if (h > 12) {         h = h - 12;         diem = "pm";     }      if (h < 10) {         h = "0" + h;     }      if (m < 10) {         m = "0" + m;     }      if (s < 10) {         s = "0" + s;     }      var myclock = document.getelementbyid ("clockdisplay");     myclock.textcontent = h + ":" + m + ":" + s + " " + diem;      settimeout ('rendertime()', 1000); } rendertime(); </script> 

this being applied css style have created can have clock in specific typeface.

you can add or subtract hours date with

currenttime.sethours(currenttime.gethours()+offset); 

where offset number of hours.

i updated jsfiddle line , function accepts parameter offset. not utc offset, how many hours add system time. can current utc offset currenttime.gettimezoneoffset()/60

demo


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -