I want to find date by subtracting X number of days from a particular date in JavaScript. My JavaScript function accepts 2 parameters. One is the date value and the other i
Here's an example, however this does no kind of checking (for example if you use it on 2009/7/1 it'll use a negative day or throw an error.
function subDate(o, days) { // keep in mind, months in javascript are 0-11 return new Date(o.getFullYear(), o.getMonth(), o.getDate() - days);; }