Sets the year of the given date and returns a new Date instance.
The original date.
The year to set.
A new Date with the updated year.
setYear(new Date('2024-07-23'), 2025); // → 2025-07-23 Copy
setYear(new Date('2024-07-23'), 2025); // → 2025-07-23
Sets the year of the given date and returns a new Date instance.