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.
getFullYear()
메서드는 주어진 날짜의 현지 시간 기준 연도를 반환합니다.
getYear()
메서드 대신 이 메서드를 사용하세요.
시도해보기
const moonLanding = new Date("July 20, 69 00:20:18");
console.log(moonLanding.getFullYear());
// Expected output: 1969
구문
js
dateObj.getFullYear();
반환 값
현지 시간에 따라, 주어진 날짜의 연도에 해당하는 숫자.
설명
getFullYear()
가 반환하는 값은 절댓값입니다. getFullYear()
는 1000년과 9999년 사이의, 1995년과 같은 날짜에 대해서는 네 자리 숫자를 반환합니다. 이 메서드를 사용해야 2000년 이후의 날짜에 대해서도 호환을 유지할 수 있습니다.
예제
getFullYear()
사용하기
다음 예제에서는 현재 연도의 네 자릿값을 변수 year
에 할당합니다.
js
var today = new Date();
var year = today.getFullYear();
명세
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getfullyear |
브라우저 호환성
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.