title: JavaScript subtract time in moment used in reactJS
body: <p>I am using <strong>React Js</strong> and I would like to perform a subtract time in <strong>JavaScript</strong> with <em>moment</em> library.</p>
  <p>I tried my code as follows:</p>
  <pre><code>timecheck(){
      var time1 = moment().format(&quot;09:00:00&quot;);
      var time2 = moment().format(&quot;00:03:15&quot;);
      var timeStr = time2.split(':');
      var h = timeStr[0];
      var m = timeStr[1];
      var s = timeStr[2];
  
      var time3 = moment(time1).subtract({'hours': h, 'minutes': m, 'second': s}).format('hh:mm:ss');
      console.log(time3);
    }
  </code></pre>
  <p>The above code was my <code>timecheck</code> function, I would like to perform <code>time3 = time1 - time2</code>, it console log as <code>InvalidDate</code></p>
  <p>May I know where is my syntax error?</p>