title: Convert array data to object
body: <p>so I have this array.</p>
  
  <pre><code>["2020-01-31 18:31:01", "2020-02-03 14:04:30", "2020-02-04 05:58:48", "2020-02-04 14:11:16"]
  </code></pre>
  
  <p>and I like to convert it to object.</p>
  
  <pre><code>0: {date: "2020-01-31", time: ["8:31:01"]}
  1: {date: "2020-02-03", time: ["4:04:30"]}
  2: {date: "2020-02-04", time: ["5:58:48", "14:11:16"]}
  </code></pre>
  
  <p>But I 'm getting this result</p>
  
  <pre><code>0: {date: "2020-01-31", time: "8:31:01"}
  1: {date: "2020-02-03", time: "4:04:30"}
  2: {date: "2020-02-04", time: "5:58:48"}
  </code></pre>
  
  <p>This is my code</p>
  
  <pre><code>var times = response.data.time;
  var dates = [];
  var t = [];
  var d = '';
  var newData = [];
  times.forEach(time =&gt; {
  
     var da = time.substring(0, 10);
     var ti = time.substring(12, 19);
  
     if(d == da) {
  
       t.push(ti);
  
     } else {
  
       d = da
  
       var dt = {date: da, time: ti};
       newData.push(dt);
  
     }
  
  
   });
  </code></pre>
  
  <p>I'm having a hard time to figure this out hope you can help me.</p>
  
  <p>Thanks.</p>