addDays()
addDays(
input,amount):Date
Defined in: utils/date/addSubDays.ts:34
Add a number of calendar days to a date-like value.
This helper:
- Accepts
Date, ISO-likestring, or timestampnumber. - Works in local time and respects month/year rollover.
- Never mutates the input; it always returns a new
Dateinstance.
Parameters
input
Base date (local time).
string | number | Date
amount
number
Number of calendar days to add. Can be negative. Must be a finite number, otherwise a RangeError is thrown.
Returns
Date
A new Date instance representing input + amount days.
Throws
- When
inputcannot be converted into a validDate(as determined by toDateStrict).- When
amountis not a finite number.
- When
Example
ts
const d = new Date(2024, 0, 10); // Jan 10, 2024
addDays(d, 5); // Jan 15, 2024
addDays(d, -1); // Jan 9, 2024