title: How to use Moment.JS to check whether the current time is between 2 times
body: <p>Say the current time is <code>09:34:00</code> (<code>hh:mm:ss</code>), and I have two other times in two variables:</p>
  
  <pre><code>var beforeTime = '08:34:00',
      afterTime = '10:34:00';
  </code></pre>
  
  <p>How do I use Moment.JS to check whether the current time is between <code>beforeTime</code> and <code>afterTime</code>?</p>
  
  <p>I've seen <a href="http://momentjs.com/docs/#/query/is-between/" rel="noreferrer"><code>isBetween()</code></a>, and I've tried to use it like:</p>
  
  <pre><code>moment().format('hh:mm:ss').isBetween('08:27:00', '10:27:00')
  </code></pre>
  
  <p>but that doesn't work because as soon as I format the first (current time) moment into a string, it's no longer a moment object. I've also tried using:</p>
  
  <pre><code>moment('10:34:00', 'hh:mm:ss').isAfter(moment().format('hh:mm:ss')) &amp;&amp; moment('08:34:00', 'hh:mm:ss').isBefore(moment().format('hh:mm:ss'))
  </code></pre>
  
  <p>but I get <code>false</code>, because again when I format the current time, it's no longer a moment.</p>
  
  <p>How do I get this to work?</p>