title: JS date compare issue
body: <p>I want to compare a init time with current time and results are weird.</p>
  
  <p>From a String a build a date like shown:</p>
  
  <pre><code>fechIni = "2019-02-07"
  timeIni = "17:40"
  var datepartsIni = fechIni.split("-");
  var horapartsIni = timeIni.split(":");
  var dateIni = new Date(datepartsIni[0], datepartsIni[1], datepartsIni[2], horapartsIni[0], horapartsIni[1]);
  </code></pre>
  
  <p>if print dateIni, I got something like: Thu Mar 07 2019 17:40:00 GMT-0300 (hora de verano de Chile) Witch I think is right.</p>
  
  <p>Then, I compare that date with current date (for not allowing doing something).</p>
  
  <pre><code>var currentdate = new Date();
  </code></pre>
  
  <p>When I compared them, (imagine dateIni is earlier than currentdate) with something like this:</p>
  
  <pre><code>if (dateIni &gt; currentdate) {... do stuff ...}
  </code></pre>
  
  <p>I got true when it should be false. I have try with .valueOf(), convert to milis, convert to epoch and calculating difference... but I can't do the trick.</p>
  
  <p>I attach a screenshot of console output and code.</p>
  
  <p><a href="https://i.stack.imgur.com/WDfcd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WDfcd.png" alt="Code"></a></p>
  
  <p><a href="https://i.stack.imgur.com/Jqs41.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jqs41.png" alt="Code2"></a></p>
  
  <p>UPDATE:
  Solved!! The trick was setting the date:</p>
  
  <pre><code>var dateFin = new Date(datepartsFin[0], datepartsFin[1] - 1, datepartsFin[2], horapartsFin[0], horapartsFin[1]);
  </code></pre>
  
  <p>Instead of</p>
  
  <pre><code>var dateFin = new Date(datepartsFin[0], datepartsFin[1], datepartsFin[2], horapartsFin[0], horapartsFin[1]); //WRONG in my case
  </code></pre>