title: Solution for process.env.TZ = 'UTC' in Node for Windows?
body: <p>I was trying to test my Postgres database to make sure everything was being added properly and would include a hardcoded date in this format <code>2029-01-22T16:28:32.000Z</code>.</p>
  
  <p>Here is the table for it: </p>
  
  <pre><code>CREATE TABLE blogful_articles (
      id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
      title TEXT NOT NULL,
      content TEXT,
      date_published TIMESTAMP DEFAULT now() NOT NULL
  );
  </code></pre>
  
  <p>I expect to get back <code>2029-01-22T16:28:32.000Z</code> but get back <code>2029-01-23T00:28:32.000Z</code>because Windows would automatically adjust it for the timezone difference and my test would fail. </p>
  
  <p>It should automatically adjust for daylight savings time but here is my solution:</p>
  
  <pre><code>function adjustingForTimezone(dateToAdjust) {
    const offsetInMilliseconds = dateToAdjust.getTimezoneOffset() * 60000;
    const theDateWithOffsetAdded =
      Date.parse(dateToAdjust) - offsetInMilliseconds;
    const adjustedTime = new Date(theDateWithOffsetAdded);
    return adjustedTime;
  }
  </code></pre>
  
  <p>Here is how I used it:</p>
  
  <pre><code>app.get("/articles", (req, res, next) =&gt; {
    const knexInstance = req.app.get("db");
    ArticlesService.getAllArticles(knexInstance)
      .then(articles =&gt; {
        const os = process.platform
  
        function adjustingForTimezone(dateToAdjust) {
          const offsetInMilliseconds = dateToAdjust.getTimezoneOffset() * 60000
          const theDateWithOffsetAdded = Date.parse(dateToAdjust) - offsetInMilliseconds
          const adjustedTime = new Date(theDateWithOffsetAdded)
          return adjustedTime
        }
  
        res.json(
          articles.map(article =&gt; ({
            id: article.id,
            title: article.title,
            style: article.style,
            content: article.content,
            date_published: os === "win32" ? adjustingForTimezone(article.date_published) : new Date(article.date_published)
          }))
        );
      })
      .catch(next);
  });
  </code></pre>
  
  <p>I made the <code>adjustingForTimezone</code> function that should adjust it automatically, is there any way that I could improve it?  What are the potential pitfalls of using this in my code? </p>