title: Alternative to casting UTC Date in Javascript?
body: <p>I wish to create a new Date in JS, but have it be cast as UTC time. For example, suppose <code>castAsUTC()</code> produces the following desired effect:</p>
  
  <pre><code>var x = new Date('2019-01-01T00:00:00') // In local time (PST)
  castAsUTC(x).toISOString(); // =&gt; '2019-01-01T00:00:00Z'
  // x.toISOString() gives us '2019-01-01T08:00:00Z', which is undesired
  </code></pre>
  
  <p>Currently, my function looks like this:</p>
  
  <pre><code>function castAsUTC(date) {
    return new Date(x.toLocaleString() + '+00:00');
  }
  </code></pre>
  
  <p>Is there a cleaner/nicer way of producing the same effect? Thanks in advance!</p>
  
  <p>EDIT: To be more specific, I'm interested in transforming the date's timezone, without changing its actual value with as little arithmetic as possible. So calling <code>.toISOString()</code> will produce the same date as it is in local time.</p>
  
  <p>I am currently using the <code>moment-timezone</code> library, but I can't seem to get the desired effect using that, either. I would definitely accept an answer that uses Moment.js</p>