You cannot compare dates as you are doing.
When you initialize date object with new Date(), it is set with current time.
So
var today = new Date("2016-10-19"); //----> current date here
var anothertoday = new Date();
shall never be the same
anothertoday > today //-----> true
The above expression evaluates to true because if you see the time of both the dates
today.getHours() //---> 0
anothertoday.getHours() //---> current time shall be displayed
To compare it on the basis of only date you need to set time of anothertoday to 0 by anothertoday.setHours(0,0,0,0)
Now the above expression should evaluate to false
anothertoday > today //---->false
So in your case your code should be similar to this
var today = new Date();
$scope.date1 = "2016-10-18";
$scope.datearr = $scope.date1.split("-");
var yesterday = new Date($scope.datearr[0],$scope.datearr[1] - 1,$scope.datearr[2]);
today.setHours(0,0,0,0); //----> set time to 0 hours
if(today > yesterday)
console.log("Please select todays date or upcoming date");
"2016-10-18".split('-').reverse().join(',')becomes"18,10,2016"which isn't any kind of date formatnew Date('2016-10-18')seems to create the correctDateinstance just fine. Not sure at all what you're trying to achieve2016-10-06this ,its working fine.