如果是减少,那么里面的值为负数即可

const addSeconds = function (dateTime, seconds){
  const numberOfMlSeconds = dateTime.getTime();
  const addMlSeconds = seconds * 1000;
  return new Date(numberOfMlSeconds + addMlSeconds);
}

const addMinutes = function (dateTime, minutes){
  return addSeconds(dateTime, minutes * 60);
}

const addHours = function (dateTime, hours){
  return addMinutes(dateTime, hours * 60);
}

const addDays = function (dateTime, days){
  return addHours(dateTime, days * 24);
}

const addWeeks = function (dateTime, weeks){
  return addDays(dateTime, weeks * 7);
}

标签: none