addYears

Modified on Tue, 22 Aug 2023

Description

Use this function to add the specified number of years to the given date.

Syntax

addYears(date: Date | number, amount: number): Date

Returns

Return ValueDescription
DateReturns the resulting date after adding the specified number of years.

Sample

ExampleResultDescription
addYears (2023-04-03, 2)2025-04-03Adds 2 years to the input date (2023-04-03), resulting in a new date of 2025-04-03.

To view all the Date functions, click here.

See Also