title: Moment js date time compare
body: <p>I'm making an API call from a javascript function which is returning a JSON response correctly.  But when stepping through the JSON response I'm getting a deprecation warning as well as an error at Function.createFromInputFallback (moment.js line:320) when I hit the line with <code>moment().isSameOrBefore</code>.  I'm fairly new to javascript and especially the moment package for Node. </p>
  
  <p>Basically, I would like to establish which predicted tide is the closest to the current time when this function is executed. Is this the correct way to use the <code>moment().isSameOrBefore</code> paramter and/or should I modify the code to go about this differently?</p>
  
  <p><strong>Here's the JSON:</strong></p>
  
  <pre><code>{ "predictions" : [ {"t":"2018-06-08 03:06", "v":"3.795", "type":"H"},{"t":"2018-06-08 09:25", "v":"0.443", "type":"L"},{"t":"2018-06-08 15:51", "v":"3.884", "type":"H"},{"t":"2018-06-08 22:01", "v":"0.778", "type":"L"} ]}
  </code></pre>
  
  <p><strong>Here's my function:</strong></p>
  
  <pre><code>const getTide = require('./modules/getTide.js');
  
  var moment = require('moment');
  
  async function testMod() {
      await getTide.getQuote().then(function(value){
          const parsedData = JSON.parse(value);       
          let text = " "; 
          // This loop steps through the JSON response row by row to test the data
          var i;
          for (i = 0; i &lt; parsedData.predictions.length; i++) { 
              text += 'Record #' + i + ' = ' + parsedData.predictions[i].t + " " + parsedData.predictions[i].v + " " + parsedData.predictions[i].type + " - ";            
              let curDateTime = moment().format('LLL');           
              let theDate = moment(parsedData.predictions[i].t).format('LLL'); 
              let fromNow = moment(parsedData.predictions[i].t).fromNow(); 
              if (parsedData.predictions[i].type === "H") {
                      console.log('High tide for ' + parsedData.predictions[i].t + ', at ' + parsedData.predictions[i].v + ' vertical Feet. ');                                  
                      if (moment(theDate).isSameOrBefore(curDateTime)) {
                         console.log('It is currently ' + curDateTime + ' and that high tide was ' + fromNow);
                      } else {
                         console.log('It is currently ' + curDateTime + ' and that high tide is ' + fromNow + ' from now!');  
                      }                   
                    } else {
                      console.log('Low tide for ' + parsedData.predictions[i].t + ', at ' + parsedData.predictions[i].v + ' vertical Feet. ');
                      if (moment(theDate).isSameOrBefore(curDateTime)) {
                         console.log('It is currently ' + curDateTime + ' and that low tide was ' + fromNow);
                      } else {
                         console.log('It is currently ' + curDateTime + ' and that low tide is ' + fromNow + ' from now!');   
                      }               
                    }     
          }
      }, function(error){
          console.log("problem");
      });
  }
  
  testMod();
  </code></pre>