title: How to filter data by date in Angular js
body: <p>I want to filter data by event date. I have the following options to filter: current day, current month and current year. Below you can see what I have so far:</p>
  
  <pre><code>function dateCtrl($scope) {
      var d = new Date();
      var curr_date = d.getDate();
      var curr_month = d.getMonth();
      var curr_year = d.getFullYear();
  
      $scope.dateToday = Date.parse(curr_month + "/" + curr_date + "/" + curr_year);
      $scope.dateRange = ""; 
  
      $scope.dataModels = [
      {age:5,name:'John Lennon',eventDate:"1390524400000"},
      {age:12,name:'Nick Young',eventDate:"1377500400000"},               
      {age:10,name:'Mike Johnson',eventDate:"1374044400000"},
      {age:15,name:'Lisa Leslie',eventDate:"1335942000000"}
      ];
  
      $scope.eventDateFilter = function(column) {
          if(column === 'today') {
              $scope.dateRange = $scope.dateToday;
          } else if (column === 'currentWeek') {
              //need logic
          } else if (column === 'currnetMonth') {
             //need logic        
          } else if (column === 'currnetYear') {
              //need logic            
          }else {
              $scope.dateRange = "";
          }
      }
  }
  </code></pre>
  
  <p>and here I have the controller:</p>
  
  <pre><code>&lt;div ng:controller="dateCtrl"&gt;
  Date Filter
      &lt;ul class="inline"&gt;
          &lt;li&gt;&lt;a href ng-click="eventDateFilter('all')"&gt;All&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href ng-click="eventDateFilter('today')"&gt;Today&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href ng-click="eventDateFilter('pastWeek')"&gt;Past Week&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href ng-click="eventDateFilter('pastMonth')"&gt;Past Month&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;table class="table"&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Age&lt;/th&gt;
              &lt;th&gt;Event Date&lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr ng:repeat="data in dataModels | filter:dateRange"&gt;
              &lt;td&gt;{{data.name}}&lt;/td&gt;
              &lt;td&gt;{{data.age}}&lt;/td&gt;
              &lt;td&gt;{{data.eventDate | date:medium}}&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;    
  &lt;/div&gt;
  </code></pre>
  
  <p>I have the entire code here : <a href="http://jsfiddle.net/c6BfQ/164/" rel="nofollow">The code</a></p>