en.javascript.info/1-js/4-data-structures/11-datetime/4-get-date-ago/_js.view/solution.js
2015-03-09 18:48:58 +03:00

6 lines
No EOL
141 B
JavaScript

function getDateAgo(date, days) {
var dateCopy = new Date(date);
dateCopy.setDate(date.getDate() - days);
return dateCopy.getDate();
}