title: group by array of objects with condition and custom key
body: <p>I have below array of objects,</p>
  <pre><code>[{
  
      a: 1,
      created_on: '2021-04-23 10:00:01',
  }, {
      b: 1,
      created_on: '2021-04-24 09:03:01',
  }, {
      b: 1,
      created_on: '2021-04-24 13:03:01',
  }]
  </code></pre>
  <p>First, I need to group by with date ignoring times.</p>
  <p>So,</p>
  <pre><code>{
   &quot;2021-04-23&quot;: [{
      a: 1,
      created_on: '2021-04-23 10:00:01',
    }],
  ....
  }
  </code></pre>
  <p>If it were a date like <code>created_on:  '2021-04-23'</code>, I could use <code>lodash/groupBy</code>.</p>
  <p>I still could use it but now it involves some condition to be applied to convert those <code>created_on</code> into date format.</p>
  <p>Further, I also need to group by those each grouped by date result as such that their <code>created_on</code> falls within a time interval.</p>
  <pre><code>&quot;SALES_SLOTS&quot;: [
      {
        &quot;slot&quot;: &quot;00:00-04:00&quot;
      },
      {
        &quot;slot&quot;: &quot;04:00-08:00&quot;
      }, 
      {
        &quot;slot&quot;:&quot;08:00-12:00&quot;
      }, 
      {
        &quot;slot&quot;:&quot;12:00-16:00&quot;
      },
      {
        &quot;slot&quot;:&quot;16:00-20:00&quot;
      },
      {
        &quot;slot&quot;:&quot;20:00-24:00&quot;
      }
    ],
  </code></pre>
  <p>So, if <code>created_on: '2021-04-23 10:00:01'</code>, it should come in the group,</p>
  <pre><code>{
    &quot;08:00-12:00&quot;: [{
       a: 1,
       created_on: '2021-04-23 10:00:01',
    }]
  }
  </code></pre>
  <p>So, first results should be grouped by date from created on and then elements in each groups should be further group by defined time slots.</p>
  <p>I suppose, if I could use group by condition, I could achieve the desired result.</p>