from Date I just want to subtract 1 day in javascript/angularjs

You can simply subtract one day from today date like this:

var yesterday = new Date(new Date().setDate(new Date().getDate()-1));

The simple answer is that you want to subtract a days worth of milliseconds from it. So something like the following

var today = new Date('October 13, 2014 22:34:17');
var yesterday = new Date(today.getTime() - (24*60*60*1000));
console.log(yesterday);

The problem with this is that this really gives you 24 hours earlier, which isn't always a day earlier due to things such as changes in Daylight Saving Time. If this is what you want, fine. If you want something more sophisticated, check out moment.js


You need to specify what amount of time you are subtracting. At the moment its 1, but 1 what? Therefore, try getting the days using getDate() and then subtract from that and then set the date with setDate().

E.g.

var temp = new Date("October 13, 2014 22:34:17");
temp.setDate(temp.getDate()-1);