title: Date.toISOString() but local time instead of UTC
body: <p>Let's say we have this datetime:</p>
  
  <pre><code>var d = new Date("Sat Jul 21 2018 14:00:00 GMT+0200");
  </code></pre>
  
  <p>Exporting it as a string (<code>console.log(d)</code>) gives inconsistent results among browsers:</p>
  
  <ul>
  <li><p><code>Sat Jul 21 2018 14:00:00 GMT+0200 (Paris, Madrid (heure d’été))</code> with Chrome</p></li>
  <li><p><code>Sat Jul 21 14:00:00 UTC+0200 2018</code> with Internet Explorer, etc.</p></li>
  </ul>
  
  <p>so we can't send datetime to a server with an <strong>unconsistent format</strong>.</p>
  
  <p>The natural idea then would be to ask for an ISO8601 datetime, and use <code>d.toISOString();</code> but it gives the UTC datetime: <code>2018-07-21T12:00:00.000Z</code> whereas I would like the local-timezone time instead:</p>
  
  <pre><code>2018-07-21T14:00:00+0200
  or
  2018-07-21T14:00:00
  </code></pre>
  
  <p><strong>How to get this (without relying on a third party dependency like momentjs)?</strong></p>
  
  <p>I tried this, which <em>seems to work</em>, but <strong>isn't there a more natural way to do it?</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var pad = function(i) { return (i &lt; 10) ? '0' + i : i; };
  
  var d = new Date("Sat Jul 21 2018 14:00:00 GMT+0200");
  Y = d.getFullYear();
  m = d.getMonth() + 1;
  D = d.getDate();
  H = d.getHours();
  M = d.getMinutes();
  S = d.getSeconds();
  s = Y + '-' +  pad(m) + '-' + pad(D) + 'T' + pad(H) + ':' + pad(M) + ':' + pad(S);
  console.log(s);</code></pre>
  </div>
  </div>
  </p>