title: Compare and filter data with date in MM/DD/YYYY format from current date using using new Date() while subtracting new Date() from user input value
body: <p>Trying to compare the new Date(today's date) in 2015-02-21T21:48:48.137Z  format with date in  MM/DD/YYYY format which is my json data. I would like to  filter all the data before today's days based on user input based on number of day's user enters(getting data before no certain number of days)..I can get the number of days and subtract it from todays date. Don't know how to compare this date with Json date value in MM/DD/YYYY format.Should i parse the Date() in order to compare with JSON data in MM/DD/YYYY format</p>
  
  <p>I am able to take user input and subtract it from today's date based on 2015-02-20T21:48:48.137Z format using new Date().My data is MM/DD/YYYY format so need a way to compare the value i get after subtracting with date in MM/DD/YYYY format. Do i need to change parameter in my filter and input both date and value through ng-model.</p>
  
  <p><a href="http://plnkr.co/edit/unB6m8ZyqGnmiYfeaLoP?p=preview" rel="nofollow">http://plnkr.co/edit/unB6m8ZyqGnmiYfeaLoP?p=preview</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Code goes here
  
  var app = angular.module('tempfilter', []);
  
  app.controller('MainCtrl', function($scope) {
    $scope.sensordata = [{
      name: 'Rob',
      "Date": "2015-02-15",
      "Temp": 42
    }, {
      name: 'Bob',
      "Date": "2015-02-19",
      "Temp": 50
    }, {
      name: 'Tom',
      "Date": new Date().getDate(),
      "Temp": 60
    }, {
      name: 'Sinclair',
      "Date": new Date(),
      "Temp": 65
    }];
    $scope.filter = {
      value: 2
    };
  
  });
  
  app.filter('tempo', function() {
    return function(items, field, value) {
      var filtered = [];
      var d = new Date(); // today!
      !d.setDate(d.getDate() - value); //date before today
  
      angular.forEach(items, function(item) {
        if (item[field] &lt;= d) {
          filtered.push(item);
        }
      });
      return filtered;
    };
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"&gt;&lt;/script&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html ng-app="tempfilter"&gt;
  
  &lt;head lang="en"&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;DateFilter&lt;/title&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"&gt;&lt;/script&gt;
    &lt;script&gt;
      document.write('&lt;base href="' + document.location + '" /&gt;');
    &lt;/script&gt;
    &lt;script src="script.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body ng-controller="MainCtrl"&gt;
    Number of days before today
    &lt;input type="number" ng-model="filter.value"&gt;
    &lt;p id="demo"&gt;Showing values lower than {{ filter.value }}&lt;/p&gt;
    Filtered list:
    &lt;ul&gt;
      &lt;li ng-repeat="s in sensordata | tempo:'Date':filter.value"&gt;{{s.Date|date:'MM/dd/yyyy'}} {{s.name}} {{s.Temp}}
      &lt;/li&gt;
    &lt;/ul&gt;
  
    Full List:
    &lt;ul&gt;
      &lt;li ng-repeat="s in sensordata "&gt;{{s.Date|date}} {{s.name}} {{s.Temp}}
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>