CyrefJS
CCyrefJS
فا
Back to documentation
Date/Since 1.38.0

addDays

Returns a new Date with a specified number of days added to the given date without modifying the original Date object.

addDays(date, amount):Date

Parameters

dateDaterequired

The date to which the specified number of days will be added.

amountnumberrequired

The number of days to add to the date. Negative values subtract days.

Returns

Date

A new Date object with the specified number of days added.

Examples

01

Basic usage

Add days to a Date object.

TypeScript
import { addDays } from "@cyref/js";

const date = new Date("2026-01-10");

const result = addDays(date, 5);

console.log(result);
// 2026-01-15
02

Subtract days

Negative values can be used to subtract days from the date.

TypeScript
import { addDays } from "@cyref/js";

const date = new Date("2026-01-10");

const result = addDays(date, -3);

console.log(result);
// 2026-01-07
03

Crossing month boundaries

The function automatically handles dates that move into the next or previous month.

TypeScript
import { addDays } from "@cyref/js";

const date = new Date("2026-01-30");

const result = addDays(date, 3);

console.log(result);
// 2026-02-02
04

Original date remains unchanged

addDays creates a new Date object, so the original date is not modified.

TypeScript
import { addDays } from "@cyref/js";

const date = new Date("2026-05-10");

const result = addDays(date, 7);

console.log(date);
// 2026-05-10

console.log(result);
// 2026-05-17
05

Adding zero days

Adding zero days returns a new Date with the same date value.

TypeScript
import { addDays } from "@cyref/js";

const date = new Date("2026-06-15");

const result = addDays(date, 0);

console.log(result);
// 2026-06-15
Built with@cyref/js·Official documentation