title: Difference between JavaScript and Postgres Epoch
body: <p>I would have thought these two statements would have returned the same value:</p>
  
  <p><strong>Javascript (Chrome)</strong></p>
  
  <pre><code>new Date(2018, 3, 1).getTime() /1000;
  =&gt; 1522533600
  </code></pre>
  
  <p><strong>Postgres</strong>    </p>
  
  <pre><code>SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2018-03-01 00:00:00 ');
  =&gt; 1519858800.0
  </code></pre>
  
  <p>As you can see there is a huge difference. What am I missing here?</p>
  
  <p><strong>Timezone information</strong></p>
  
  <p>Both queries are performed in the same timezone, confirmed as below.</p>
  
  <p>Postgres</p>
  
  <pre><code>SELECT EXTRACT(TIMEZONE FROM now())/3600.0;
  =&gt; 2.0
  </code></pre>
  
  <p>Javascript </p>
  
  <pre><code>new Date().getTimezoneOffset();
  -120
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <p>Thank you @yelliver and @Vao Tsun, the problem was that Javascript starts the month with zero. Confirming:</p>
  
  <pre><code>new Date(2018, 2, 1).getTime() /1000;
  =&gt; 1519858800
  </code></pre>