Adding days to a given date object - Node.js Date

Node.js examples for Date:Day

Description

Adding days to a given date object

Demo Code


/**/*from  w  ww .ja  v a 2  s  .co m*/
 * @description Allows for easy date manipulation. In particular, adding days
 *   to a given date object.
 * @param {Date} date: The date to be modified.
 * @param {Number} days: The number of days into the future to shift the
 *   provided "date".
 * @returns {Date} The resultant Date, with days added.
*/
addDays: function (date, days) {
  var result = new Date(date);
  result.setDate(result.getDate() + days);
  return result;
}

Related Tutorials