title: Avoid timezone correction for JavaScript Date
body: <p>I have a JavaScript function that takes a number (1-31), creates a <code>Date</code> and sends it to a server via an <code>AJAX</code> request:</p>
  <pre><code>sendDate(d) {
      let date = new Date(this.year, this.month, d);
      htmx.ajax(&quot;GET&quot;, &quot;/some/url&quot;, { values: { &quot;date&quot;: date.toISOString() } });
  }
  </code></pre>
  <p>The problem is, that JavaScript is doing some timezone correction which has the effect, that if I create a date like <code>new Date(2022, 09, 14)</code> I get a date <code>Wed Sep 14 2022 00:00:00 GMT+0200 (Central European Summer Time)</code> which when converted to ISO format becomes <code>2022-09-13T22:00:00.000Z</code>, ie. the previous day.</p>
  <p>I know I can use <code>.toLocaleDateString()</code>, but I would like to stick to the ISO-format and I would also like to avoid hacky solutions such as always creating the date with some specified time at the middle of the day or whatever.</p>
  <p>Is there a simple way to create a regular date object and pass it on to a server without timezone shenanigans?</p>