title: How to calculate difference between 2 times in React Native?
body: <p>I am trying to calculate difference between 2 times.
  But it is not working as I expected.</p>
  <p>e.g: In the following photo</p>
  <blockquote>
  <ol>
  <li>current Time</li>
  <li>item created Time</li>
  <li>current Time converted to millisecond</li>
  <li>created Time converted to millisecond</li>
  <li>current - created (millisecond)</li>
  </ol>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/5M2vn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5M2vn.png" alt="enter image description here" /></a></p>
  <p>As shown image, I expected the difference 17h 19min 27s. But it gave me 5h 19min 27s. (Just 12 hours difference)</p>
  <p>I am not sure that is AM(PM) problem or Time zone problem. I used following method.</p>
  <pre><code>&lt;Text red&gt;{dayjs(new Date().getTime()).format('YYYY-MM-DD HH:mm:ss')}&lt;/Text&gt;
  &lt;Text red&gt;{dayjs(new Date(`${item.created_at.slice(0, 10)}T${item.created_at.slice(11, 19)}`).getTime()).format('YYYY-MM-DD hh:mm:ss')}&lt;/Text&gt;
  &lt;Text red&gt;{new Date().getTime()}&lt;/Text&gt;
  &lt;Text red&gt;{new Date(`${item.created_at.slice(0, 10)}T${item.created_at.slice(11, 19)}`).getTime()}&lt;/Text&gt;
  &lt;Text red&gt;{new Date().getTime()-new Date(`${item.created_at.slice(0, 10)}T${item.created_at.slice(11, 19)}`).getTime()}&lt;/Text&gt;
  </code></pre>
  <p>How can I get exact difference? In a word, <code>new Date().getTime()</code> is not working as I expected.</p>