title: Setting up conditionals with moment.js
body: <p>I'm using momentJS to parse the dates and times in my application, but I ran into a problem when trying to set conditionals with the times.</p>
  <p>For example: I need to validate a field where I need the time of said field to be no more than 30 minutes before the time of another field (it's an aviation practice, the pilot needs to validate his presence no more than 30 minutes before the engine starts).</p>
  <p>I've tried to set a var with the time limit and the IsAfter query, but I keep getting repeating times instead of the desired result of 'time -30 minutes'. Here's the code.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var firstTime = new moment(
    this._dateTimeToDateSQL(
      this.form.acionamento,
      $sessao.getDateFormat() + ' HH:MM'
    )
  )
  
  var secondTime = new moment(
    this._dateTimeToDateSQL(
      this.form.tripulacao[0].apresentacao,
      $sessao.getDateFormat() + ' HH:MM'
    )
  )
  
  var timeLimit = moment(firstTime.subtract(30, 'minutes'))
  
  if (moment(secondTime).isAfter(firstTime)) {
    this.form.tripulacao[0].err = 'error'
    pass = false
  } else if (moment(secondTime).isAfter(timeLimit)) {
    this.form.tripulacao[0].err =
      'time limit reached'
    pass = false
  } else {
    this.form.tripulacao[0].err = ''
  }</code></pre>
  </div>
  </div>
  </p>