GlideDateTime - addYearsLocalTime(Number years)

Adds a specified number of years to the current GlideDateTime object. A negative parameter subtracts years.

The method determines the local date and time equivalent to the value stored by the GlideDateTime object, then adds or subtracts years using the local date and time values.

Table 1. Parameters
Name Type Description
years Number The number of years to add. To subtract use a negative value.
Table 2. Returns
Type Description
void

Scoped equivalent

To use the addYearsLocalTime() method in a scoped application, use the corresponding scoped method: Scoped GlideDateTime - addYearsLocalTime(Number years).

var gdt = new GlideDateTime("2010-08-31 08:00:00");
gdt.addYearsLocalTime(1);
gs.print(gdt.getDate());

Output: 2011-08-31