Date.prototype.getUTCFullYear()
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.
O método getUTCFullYear()
retorna o ano na data indicada de acordo com o horário universal.
Experimente
const date1 = new Date("December 31, 1975, 23:15:30 GMT+11:00");
const date2 = new Date("December 31, 1975, 23:15:30 GMT-11:00");
console.log(date1.getUTCFullYear());
// Expected output: 1975
console.log(date2.getUTCFullYear());
// Expected output: 1976
Sintaxe
dateObj.getUTCFullYear()
Retorna
Um número que representa o ano na data indicada de acordo com o horário universal.
Descrição
O valor retornado por getUTCFullYear()
é um número absoluto compatível com ano 2000, por exemplo, 1995.
Exemplos
Usando getUTCFullYear()
O exemplo a seguir atribui o valor de 4 dígitos do ano atual à variável year.
js
var today = new Date();
var year = today.getUTCFullYear();
Especificações
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getutcfullyear |
Compatibilidade com navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getUTCFullYear |
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.