title: How to get the next hours from now from an Array with night hours?
body: <p>I have an array of hours like this <code>['10:00:00', '11:00:00', '13:00:00', '14:00:00', '01:00:00']</code> where i have to filter and get all hours that are next to now, so if now the hour is <code>13:00:00</code> i have to cut off <code>'10:00:00' and '11:00:00'</code> but hours after midnight <code>&gt;= 00:00:00</code> should be in that array.</p>
  <p>I was trying to do something like this by using <code>.filter</code></p>
  <pre class="lang-js prettyprint-override"><code>const now = new Date();
  const orari = [
   '10:00:00',
   '11:00:00',
   '12:00:00',
   '16:00:00',
   '16:30:00',
   '00:00:00',
   '01:00:00',
   '02:00:00',
   '02:30:00',
  ];
  orari = orari.filter((o) =&gt; {
   return new Date(o) &gt; now;
  });
  </code></pre>
  <p>Or</p>
  <pre class="lang-js prettyprint-override"><code>const hours = new Date().getHours();
  const orari = [
   '10:00:00',
   '11:00:00',
   '12:00:00',
   '16:00:00',
   '16:30:00',
   '00:00:00',
   '01:00:00',
   '02:00:00',
   '02:30:00',
  ];
  orari = orari.filter((o) =&gt; {
   return Number(o.split(':')[0]) &gt; hours;
  });
  </code></pre>
  <p>But for obvious reasons (date after midnight is in the past as the day is the same) the test where times after midnight should be in the array fails.</p>
  <p><strong>Here is an example of what i would archieve:</strong></p>
  <p>If my time array is the following: <code>['10:00:00', '11:00:00', '12:00:00', '16:00:00', 16:30:00', '00:00:00', '01:00:00', '02:00:00', '02:30:00' ];</code></p>
  <p>And Time now is <code>16:00:00</code> after filtering the times i need a return array of <code>['16:30:00', '00:00:00', '01:00:00', '02:00:00', '02:30:00' ]</code></p>