setYear
Commons
stable
Return a new Date with the full year replaced by the given value. The original date is never mutated.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- daterequisDate
- The source date. It is cloned before the year is updated.
- yearrequisnumber
- The four-digit year to set (e.g. 2025).
API
Valeur de retour
La valeur retournée par cet util.
- A new Date object with the specified year.
Usage
Exemples
Extraits de code prêts à coller.
Change the year of a date