title: Changing list of time zone offset numbers to current times with JavaScript
body: <p>I am displaying a list of names and their time zone offset numbers in a table. The offset numbers are their time zone's offset from UTC. I need to change all of the offset numbers to show the current time in the person's time zone using JavaScript or jQuery.</p>
  <p>What I would like to happen is the offset numbers would be replaced with the current date/time from the <code>calcTime</code> function... any idea what I'm doing wrong?</p>
  <p>Here's my code:</p>
  <pre><code>&lt;div class=&quot;name&quot;&gt;John Doe&lt;/div&gt;&lt;div class=&quot;timezone&quot;&gt;-5&lt;/div&gt;
  &lt;div class=&quot;name&quot;&gt;Jane Doe&lt;/div&gt;&lt;div class=&quot;timezone&quot;&gt;3&lt;/div&gt;
  &lt;div class=&quot;name&quot;&gt;Jim Smith&lt;/div&gt;&lt;div class=&quot;timezone&quot;&gt;7&lt;/div&gt;
  &lt;div class=&quot;name&quot;&gt;Cathy Jones&lt;/div&gt;&lt;div class=&quot;timezone&quot;&gt;-3&lt;/div&gt;
  
  &lt;script&gt;
  $(document).ready(function() {
      setTimeout(() =&gt; {
          function calcTime(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
              return &quot;The local time is &quot; + nd.toLocaleString();
          }
  
          $(&quot;.timezone&quot;).each(function(){
              h = $(this).find(&quot;.timezone&quot;).text();
              element.innerHTML = calcTime(h); 
          //alert(calcTime('-5'));
          });
      }, 1000);
  });
  &lt;/script&gt;
  </code></pre>