Date.prototype.getFullYear()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
La méthode getFullYear()
renvoie l'année de la date renseignée d'après l'heure locale.
Cette méthode doit être utilisée à la place de getYear()
.
Exemple interactif
const moonLanding = new Date("July 20, 69 00:20:18");
console.log(moonLanding.getFullYear());
// Expected output: 1969
Syntaxe
js
dateObj.getFullYear();
Valeur de retour
Un entier correspondant à l'année de la date selon l'heure locale.
Exemples
Utiliser getFullYear()
L'exemple qui suit assigne la valeur à quatre chiffres de l'année courante à la variable année
.
js
var aujd = new Date();
var année = aujd.getFullYear();
Spécifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getfullyear |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getFullYear |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.