getFullYear()
메서드는 주어진 날짜의 현지 시간 기준 연도를 반환합니다.
getYear()
메서드 대신 이 메서드를 사용하세요.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
구문
dateObj.getFullYear()
반환 값
현지 시간에 따라, 주어진 날짜의 연도에 해당하는 숫자.
설명
getFullYear()
가 반환하는 값은 절댓값입니다. getFullYear()
는 1000년과 9999년 사이의, 1995년과 같은 날짜에 대해서는 네 자리 숫자를 반환합니다. 이 메서드를 사용해야 2000년 이후의 날짜에 대해서도 호환을 유지할 수 있습니다.
예제
getFullYear() 사용하기
다음 예제에서는 현재 연도의 네 자릿값을 변수 year
에 할당합니다.
var today = new Date();
var year = today.getFullYear();
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.3. |
ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype.getFullYear' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.prototype.getFullYear' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Date.prototype.getFullYear' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser
The compatibility table in 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.