title: What would be the proper way to filter by date
body: <p>I have an array of objects with date strings formatted as so <code>2019-03-22T13:36:18.333Z</code></p>
  
  <p>I am curious what the best course of action would be to sort these by past day, past week, past month and past year.</p>
  
  <p>I was thinking of just splitting at the <code>T</code> then splitting again at the <code>-</code></p>
  
  <p>I was also considering putting the date into the Date object and figuring it out that way.  </p>
  
  <p>What would be the most dynamic? Most efficient? etc.</p>
  
  <pre><code>const dates = [
    {created_at: '2019-03-22T13:36:18.333Z'}
    {created_at: '2019-05-22T13:36:18.333Z'}
    {created_at: '2019-03-23T13:36:18.333Z'}
    {created_at: '2019-03-24T13:36:18.333Z'}
    {created_at: '2019-01-22T13:36:18.333Z'}
  ]
  </code></pre>
  
  <pre><code>const spliteDate = (date, splitBy) =&gt; {
    if(splitBy = 'day'){
      return date.split("T")[0].split("-")[1]
    } else if(splitBy = 'month') {
      return date.split("T")[0].split("-")[2]
    } else if(splitBy = 'year') {
      return date.split("T")[0].split("-")[0]
    }
  }
  </code></pre>
  
  <pre><code>dates.filter(date =&gt; {
    return splitDate(date, 'month') === Date.now().getMonth()
  }
  </code></pre>
  
  <p>Something along these lines</p>