title: How do I get the closest date to today with an ISO date format?
body: <p>I have a function that's to read an array of objects and find:</p>
  
  <ol>
  <li><p>if <code>customerAuthorizedTime</code> is <code>null</code></p></li>
  <li><p>if <code>customerAuthorizedTime **is**</code>null`, then find the one with the closest date to today, the current day.</p></li>
  </ol>
  
  <p><strong>My attempt:</strong>
  My attempt to filter out all objects to find all the <code>customerAuthorizedTime</code> is null and then find the closest date</p>
  
  <pre><code>const filteredData = data.filter((a: MemberAppointment) =&gt; a.customerAuthorizedTime === null)
  const filteredAppointment = // use .sort() or .find() to find closest date?
  </code></pre>
  
  <p>I stop short because I'm unsure of how to find ISO dates that are closest to the current day.</p>
  
  <p><strong>My second attempt:</strong>
  I wanted to try to perform a more direct approach with <code>.find()</code>:</p>
  
  <pre><code>const currentDate = new Date().toISOString()
  const filteredAppointment = data.find((a: MemberAppointment) =&gt; a.customerAuthorizedTime === null &amp;&amp; // date is closest to today's date)
  </code></pre>
  
  <p>But the problem remains that I'm not sure how to find the closest date to today's date in ISO format. Is there a way to also satisfy this condition with <code>moment.js</code>?</p>
  
  <p>My dataset:</p>
  
  <pre><code>const data = [
    {
      'appointmentId': 403749,
      'masterAppointmentId': 403749,
      'memberPartyRoleId': 1262903,
      'description': 'Training (30 minutes)',
      'startTime': '2019-06-09T22:00:00-04:00',
      'mustCancelBy': '2019-06-09T22:00:00-04:00',
      'activityTransactionId': 19726389,
      'customerAuthorizedTime': '2019-06-09T00:33:02-04:00',
    },
    {
      'appointmentId': 403750,
      'masterAppointmentId': 403750,
      'memberPartyRoleId': 1262903,
      'description': 'Training (30 minutes)',
      'startTime': '2019-06-09T21:00:00-04:00',
      'mustCancelBy': '2019-06-09T21:00:00-04:00',
      'activityTransactionId': 19726390,
      'customerAuthorizedTime': null,
    },
    {
      'appointmentId': 403748,
      'masterAppointmentId': 403748,
      'memberPartyRoleId': 1262903,
      'description': 'Training (30 minutes)',
      'startTime': '2019-06-09T20:00:00-04:00',
      'mustCancelBy': '2019-06-09T20:00:00-04:00',
      'activityTransactionId': 19726388,
      'customerAuthorizedTime': null,
    },
    {
      'appointmentId': 403747,
      'masterAppointmentId': 403747,
      'memberPartyRoleId': 1262903,
      'description': 'Training (30 minutes)',
      'startTime': '2019-06-09T19:00:00-04:00',
      'mustCancelBy': '2019-06-09T19:00:00-04:00',
      'activityTransactionId': 19726387,
      'customerAuthorizedTime': '2019-06-09T00:13:18-04:00',
    }]
  </code></pre>