Get to know MDN better
Esta página foi traduzida do inglês pela comunidade. Saiba mais e junte-se à comunidade MDN Web Docs.
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
O método getYear() retorna o ano especificado pela data de acordo com a hora local. Por conta do fato de que getYear() não retorna anos completos ("problema do ano 2000"), este método não é mais utilizado e foi substituido pelo método getFullYear().
Nenhum.
O método getYear() retorna o ano menos 1900; então:
Para levar em consideração anos antes e depois de 2000, você deve utilizar getFullYear() ao invés de getYear() para que o ano seja especificado por completo.
O método getYear() retorna um ano de 2 ou 4 dígitos:
O segundo statement atribui o valor 95 à variável year.
O segundo statement atribui o valor 100 à variável year.
O segundo statement atribui o valor -100 à variável year.
O segundo statement atribui o valor 95 à variável year, representanto o ano 1995.
| ECMAScript® 2027 Language Specification # sec-date.prototype.getyear |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 3 de fev. de 2024 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.