title: Calculating timespans in Javascript/ECMAScript
body: <p>I've got a variable that holds a number of miliseconds which represents the timespan from now to a specified point in the future.</p>
  
  <p>I want to convert this milisecond figure into a timespan value I can display to users.</p>
  
  <p>I know I can do this the naive way with modulo arithmetic and manually displaying the result to the user, but I want to do this using the Date() API built-in to Javascript/ECMAScript.</p>
  
  <p>This is how I generate it:</p>
  
  <pre><code>var timespanInMS = timeInFuture.getTime() - now.getTime();
  var diff = new Date( timespanInMS );
  
  alert( "Hours: " + diff.getHours() + " Minutes: " + diff.getMinutes() );
  </code></pre>
  
  <p>However this only works when the user's computer is in the UTC timezone. If they're in Pacific (UTC-8) then the value of 'diff' is off by 16 hours (even though the timespanInMS figure is the same).</p>
  
  <p>Thanks</p>