title: Date Comparision in Angularjs ng-if
body: <p>I am trying to compare two dates Event Date and Current Date.I have two divisions in my HTML page.One is past events in which Event date which has crossed the current date will be automatically placed into Past events div.Another division is Upcoming Events in which event date is greater than current date.
  Condition I am using is</p>
  
  <pre><code>&lt;data-ng-if="(event.eventDate | date:'yyyy-dd-MM  HH:mm:ss')&gt;
          (todayDate | date:'yyyy-dd-MM HH:mm:ss')"&gt;
  </code></pre>
  
  <p>If it is true the added event will be placed into Upcoming events div section.Otherwise,</p>
  
  <pre><code>&lt;data-ng-if="(event.eventDate | date:'yyyy-dd-MM  HH:mm:ss')&lt;
          (todayDate | date:'yyyy-dd-MM HH:mm:ss')"&gt;
  </code></pre>
  
  <p>Then Added event will be placed into Past events section.
  In Controller.js I am writing function</p>
  
  <pre><code>$scope.init = function() {
      $scope.todayDate = new Date();
  }
  </code></pre>
  
  <p>But right now it is comparing only the day.For example if today date is 2017-07-27 and if I enter 2017-06-30 while adding events then it should go to Past Events section but it is getting added in Upcoming events section only because it is comparing only day that is 30 and 27 as in the example.And if suppose today date is 2017-07-27 and if i add event date as 2017-08-20 then it should be placed in Upcoming events but it gets added into past section.Can anyone tell me how to achieve this with yyyy-MM-dd HH:MM:SS format?It has to compare time also.</p>