I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of \'Today\', I want to get the date for \'Ye
day.setDate(day.getDate() -1); //will be wrong
this will return wrong day. under UTC -03:00, check for
var d = new Date(2014,9,19); d.setDate(d.getDate()-1);// will return Oct 17
Better use:
var n = day.getTime(); n -= 86400000; day = new Date(n); //works fine for everything