title: Convert a JavaScript Date object to a different timezone
body: <p>I have a JavaScript Date object that is manually set by the user. The problem is that when the date is created on the client, the Date constructor builds the date object according to the clients timezone.</p>
  
  <p>For example, I live in the CST timezone, but if I set my PC to EST time, then the Date constructor will construct a different date object. </p>
  
  <p><strong>The question is:</strong></p>
  
  <p>How can I convert a date object to a certain timezone? E.g. a clients machine is EST time and I need to convert the date object to CST time.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is my JS as of now</p>
  
  <pre><code>// returns local time in msecs given a UTC offset
  Date.prototype.getLocalTime = function(offset) {
      var MSEC_HOUR = 3600000; // milliseconds in an hour
      var MSEC_MIN = 60000; // milliseconds in a minute
  
      // convert client sides local time
      var utc = this.getTime() + (this.getTimezoneOffset() * MSEC_MIN);
      return utc + (offset * MSEC_HOUR);
  };
  
  var offset = -6.0; // Central Standard Time UTC offset  
  var date = form.getDate(); // get user date input   
  var msecs = date.getLocalTime(offset);
  
  // converted clients form date input to CST
  var convertedDate = new Date(msecs);
  </code></pre>