title: Comparing datetimes in javascript in format YYYY-MM-DD HH:MM:SS
body: <p>I have to compare two date times in javascript. The dates I have are of the form </p>
  
  <pre><code>YYYY-MM-DD HH:MM:SS. 
  </code></pre>
  
  <p>I am using the below code for it </p>
  
  <pre><code>var date1 = new Date("2015-08-20 09:38:20");  
  var date2 = new Date("2015-08-20 08:00:00");
  </code></pre>
  
  <p>The problem here is that when I use "/" in place of "-", I get the expected results. But when for this format I do</p>
  
  <pre><code>date1 &gt; date
  </code></pre>
  
  <p>It returns false</p>
  
  <p>Using momentJs is not an option for me and also I am getting the dates from soemewhere so would have to preserve the format. How do I compare the dates of the above given format in javascript</p>