title: Get current date, parse string to date and compare the dates
body: <p>I have a javascript/jQuery were I get a list from an AJAX call.
  I loop through this list and want to split the items into various areas, these areas are based on the date in which the item was inserted into the database.
  The date posted/stored in the database is formatted like this </p>
  
  <blockquote>
    <p>2014-03-26 15:36:37</p>
  </blockquote>
  
  <p>The areas I want to split into is today and the last seven days
  I do this with basic if statements like this:</p>
  
  <pre><code>if (postedDate == dateNow){
      alert("Today");
  }
  if (postedDate &gt; dateLastWeek &amp;&amp; postedDate &lt; dateNow){
      alert("Last seven days");
  }
  </code></pre>
  
  <p>While my date code look like this:</p>
  
  <pre><code>var dateDate = new Date();
  var dateNow = dateDate.setDate(dateDate.getDate());
  var dateLastWeek = dateDate.setDate(dateDate.getDate() - 7);
  
  $.each(data, function (index, value) {
      var postedDate = Date.parse(value.postDate);
  
      if (postedDate == dateNow){}
      if (postedDate &gt; dateLastWeek &amp;&amp; postedDate &lt; dateNow){}
  })
  </code></pre>
  
  <p>However the dates becomes these long strings like this: <img src="https://i.stack.imgur.com/Zrp7B.png" alt="enter image description here"></p>
  
  <p>Were the order is now, lastweek and the post date.</p>
  
  <p>And these does not atleast work with the if statements.</p>
  
  <p>How should I get my dates and format them inorder to compare them correctly?
  I mostly just care about splitting them into today and lastweek so hours/minutes/seconds does not really matter.</p>
  
  <p>Thank you.</p>