title: How to match and compare two timestamp?
body: <h1>The problem</h1>
  <p>I have a strange situation : I'm using firebase as DB and JS/Angular to develop my app. I'm facing this situation where I need the client check if an event's date is reached, and if it is, delete this event from the server.</p>
  <p>I guess the problem does not come from the trigger, but from my timestamps manipulations.</p>
  <p>From now, I'm using this to fill up the end date :</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>// The date format of x is : 2017-06-08T16:10
      var x = document.getElementById("dateEvent").value;
      $scope.endDate = new Date(x).getTime();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;label class="item item-select item-input item-light"&gt;&lt;input type="datetime-local" id="dateEvent"&gt;&lt;/label&gt;</code></pre>
  </div>
  </div>
  </p>
  <h1>Tests</h1>
  <p>And to test if the end date is reached, I 'm using this method :</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>// Moment.now() and endDate are timestamps, endDate comes from the HTML input
      
      if(moment.now() &gt; endDate)
      {
        // Do stuff
      }
      
      
  // Also tried to get a timestamp from the Firebase server but before using it, it is necessary to store it, so this doesn't work...
  
   var timeServ = firebase.database.ServerValue.TIMESTAMP;
  
      if(timeServ &gt; endDate)
      {
        // Do stuff
      }</code></pre>
  </div>
  </div>
  </p>
  <p>The point is, this (the first solution with moment.now() ) is working, but for some reason if nobody (clients) is connected at the right time my event remain in the DB and become &quot;immortal&quot;.</p>
  <p>An other strange thing, is I'm using timestamp that are really big, for exemple these two : 1496926321039 and 1496933687000. I'm not sure it's something normal because when I'm trying to use an online translator to check &quot;<strong>timestamp-&gt; to -&gt; date</strong>&quot; it gives me an impossible date...</p>
  <h1>EDIT :</h1>
  <p>Mmh...I find the problem. When i'm testing the app on my laptop it works, but from my iphone 2 hours are added on the endDate, of course the timestamp couldn't be correct.</p>
  <p>So now, i'm trying to figure out how can i convert a UTC date into timestamp, without using <code>new Date(x).getTime();</code>. Do you know a JS or Angular function that can handle that ?</p>