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() メソッドの代わりに、このメソッドを使用してください。

試してみましょう

構文

js
getFullYear()

返値

地方時に基づき、与えた日付の年に相当する数値。

解説

getFullYear() が返す値は絶対的な値です。1000 年から 9999 年までの日付に対して、getFullYear() は 1995 のような 4 桁の数字を返します。 2000 年以降の年について正しい値を得るには、この関数を使用してください。

getFullYear() の使用

以下の例は、変数 year に今年を表す 4 桁の数字を代入します。

js
const today = new Date();
const year = today.getFullYear();

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-date.prototype.getfullyear

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getFullYear

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報