setFullYear()

ES1+

Sets the full year for a specified date according to local time.

Syntax

date.setFullYear(year, month, day)

Parameters

year number

An integer specifying the year

month number optional

An integer between 0 and 11 representing the month

day number optional

An integer between 1 and 31 representing the day of the month

Return Value

number

The number of milliseconds between the date and UNIX epoch

Examples

JavaScript
const date = new Date('2024-01-15');
date.setFullYear(2025);
console.log(date.getFullYear());
date.setFullYear(2026, 5, 20);
console.log(date.toLocaleDateString('ko-KR'));
Output:
// 2025 2026. 6. 20.

Related Methods