title: postgresql date_trunc() function in javascript
body: <p>What would be an alternative of postgresql <code>date_trunc()</code> function in javascript?
  If I typed in pgsql the following:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select date_trunc('month', now())
  </code></pre>
  
  <p>I'd get <code>'2015-08-01 00:00:00-07'</code></p>
  
  <p>How to achieve the same with a javascript function?</p>
  
  <pre class="lang-js prettyprint-override"><code>function dateTruncate(interval, date) {
   return ???;
  }
  </code></pre>